Write Skew: The Anomaly Snapshot Isolation Does Not Catch
Two transactions each read what the other writes, both commit, and an invariant dies. Snapshot isolation allows write skew โ here is how to close the hole.
Theme
Deep dives into designing scalable, reliable systems โ URL shorteners, chat apps, rate limiters, caching, and more.
92 articles
Two transactions each read what the other writes, both commit, and an invariant dies. Snapshot isolation allows write skew โ here is how to close the hole.
A cart is a per-user document, not a reservation. What to store on the line, how to merge an anonymous cart at login, and when the price is allowed to change.
A 64-bit id from a timestamp, a worker number, and a per-millisecond sequence. How many you can issue, why the clock must not step backwards, and why JavaScript cannot hold one.
PostgreSQL 19 GA is scheduled for October 29, 2026. The WAIT command gives standbys read-your-writes, REPACK CONCURRENTLY replaces VACUUM FULL and CLUSTER, autovacuum goes parallel, and SQL/PGQ, online checksums, and FOR PORTION OF were reverted in Beta 4.
How to make POST safe to retry: the key, the stored response, the race between two identical requests, and the expiry that forgets too soon.
Why a write to the primary followed by a read from a replica shows stale data, and the practical ways to pin the next read without sending all traffic to the primary.
Heartbeat vs subscriptions, fan-out of presence, privacy, and why a boolean online flag does not survive a million concurrent sockets.
'Strong vs eventual' is a cartoon. The real spectrum โ linearizable, sequential, causal, session guarantees โ and how to pick per operation, not per system.
Authentication, routing, rate limits, transformations, and a plugin chain โ in a tier that must add ~1ms and never be the outage. Envoy/Kong architecture from scratch.
Dual writes are a lie; the database's own log is the truth. Log-based CDC, the snapshot-plus-stream handoff, schema evolution, and ordering guarantees that survive resharding.
A billion uploads a day, a legal requirement to act in hours, and irreversible mistakes in both directions: hash matching, classifier tiers, human review queues, and appeals.
One user, twenty gateway nodes, one limit of 100 req/s. Where does the counter live? Redis+Lua atomicity, the local-cache compromise, and failing open vs closed.