Databases need isolation: when dozens of transactions run at the same time, each one should feel as if it were the only one running. The gold standard is serializability — the outcome must be the same as if the transactions had run one by one, in some order.
The naive way to achieve this is to take a global lock: only one transaction at a time. That is safe but kills performance. The clever shortcut most modern databases use is Snapshot Isolation (SI): when a transaction starts, it gets a private, consistent snapshot of the database as it was at that moment. Reads never block; writes don't conflict unless two transactions touch the same row.
Snapshot Isolation is fast and handles most anomalies. But there is a subtle class it misses: write skew. Two transactions each read overlapping data, make decisions based on what they see, and each writes to different rows — so SI sees no conflict. Yet the combined result is something that could not have happened if they had run sequentially.
Serializable Snapshot Isolation (SSI), published by Cahill, Rühl, and Fekete in 2008 and shipped in PostgreSQL 9.1 (2011), fixes that gap without adding heavy locking. It watches the pattern of read and write dependencies between concurrent transactions and, if a dangerous cycle forms, aborts one transaction before the anomaly can land.
Comments
Loading comments...