Scaling Writes hard
In a database using Snapshot Isolation, which anomaly can occur that Serializability prevents?
- A Dirty Reads.
- B Non-Repeatable Reads.
- C Write Skew: Two concurrent transactions read the same data, but update disjoint sets of data based on that read, violating a logic constraint (e.g., 'Two on-call doctors' problem).
- D Lost Updates.
Answer: C. Write Skew: Two concurrent transactions read the same data, but update disjoint sets of data based on that read, violating a logic constraint (e.g., 'Two on-call doctors' problem).
Snapshot Isolation allows T1 and T2 to see the same state. If T1 sets DoctorA=Off and T2 sets DoctorB=Off (assuming at least one remains), both succeed because they don't lock the same rows. Serializability detects the dependency cycle.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- What does the 'Atomicity' property in a database transaction guarantee regarding writes?
- Your database is struggling with write traffic. You decide to 'Scale Up' (Vertical Scaling) by buying a bigger server. What is the eventual hard limit of this strategy?
- A developer sets up a 'Fire-and-Forget' write pattern (sending data without waiting for a database confirmation) to speed up the app. What is the major risk?
- Why is inserting 1,000 rows in a single 'Batch' query faster than executing 1,000 separate `INSERT` queries?
- In the Raft consensus algorithm, what mechanism prevents a 'Split Vote' (where no leader gets a majority) from stalling the cluster indefinitely?
- Your 'Logs' table has 10 billion rows and writes are getting slow. You barely access logs older than 1 year. What is the simplest strategy to improve performance?