Part 2 of 5 · 1 min read
The gap: individually valid reads, collectively invalid writes
Plain snapshot isolation has no mechanism for noticing two transactions' reads and writes interacting unsafely across each other.
Think of two referees, each separately reviewing their own replay footage of a play and ruling it legal. No one ever compares the two separate rulings against each other, to check whether, combined, they actually describe a legal sequence of events.
In plain words: plain snapshot isolation, as covered two pages ago, guarantees each transaction a consistent view of its own snapshot, but provides no mechanism for checking whether two transactions' reads and writes interact unsafely once combined, which is exactly the gap the previous page's write skew example exploited. Serializable snapshot isolation closes this gap by adding a monitoring layer on top of ordinary MVCC: it watches for a specific pattern of read-write interaction between concurrent transactions, known as a dangerous structure, that signals a potential serializability violation like write skew.
A worked example. In the on-call doctors scenario, serializable snapshot isolation's monitoring layer would notice that transaction A read a row transaction B later wrote, and transaction B read a row transaction A later wrote, a pattern it specifically watches for.
The key lines. No new SQL; detection of a dangerous structure happens internally, on top of the same statements used under plain snapshot isolation.
Dangerous structure
A dangerous structure is a specific pattern of read-write interaction between two or more concurrent transactions that serializable snapshot isolation watches for, since it signals a potential serializability violation such as write skew.
Example: two referees' separate rulings, never cross-checked against each other, failing to notice together they describe an impossible sequence of events, mirrors the gap a dangerous structure check closes.