Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
MongoDB Lab: a Single-Node Replica Set in Docker, mongosh, Compass and the Bookstore Data
The right MongoDB setup for development is a password-protected single-node replica set listening on 127.0.0.1; transactions and change streams only work on a replica set, and the member name must resolve from the host. With real output: the compose file and keyfile, rs.initiate, users and roles, mongosh, loading the Bookstore data with mongoimport, connecting from .NET and the transaction error on a standalone server.
Read Concern, Write Concern and Read Preference: Tuning Consistency in MongoDB
In MongoDB, write concern, read concern and read preference together decide how durable a write is and how fresh a read is; reading from a secondary means stale data, and read-your-writes needs majority plus a causal session. With real output from a three-member lab: a new order that is invisible on a secondary, a w:majority that timed out and was still written, 51-59 stale reads out of 200 in .NET and zero with a causal session.
Replica Sets and Sharding: Elections, the Oplog, Choosing a Shard Key and Hot Shards
When the primary of a replica set crashes, a new primary is elected in about 10 seconds and writes stop during that time; in sharding, the shard key decides whether writes pile up on one shard. With real output: two failed writes and a 10-second gap after kill -9, restoring a deleted order from a delayed member, the last 2,000 orders all going to one shard with an orderedAt key, targeted and scatter-gather queries, and a five-minute resharding.