Learn the vocabulary of a transaction reading from a consistent snapshot fixed at the moment it started.
0 / 5 completed
1 / 5
At standup, a dev mentions a database transaction isolation level where every transaction reads from a consistent snapshot of the data exactly as it looked the moment the transaction started, regardless of what other transactions commit afterward. What is this isolation level called?
Snapshot isolation is exactly this: it gives every transaction a consistent view of the data exactly as it looked the moment that transaction started, so later commits from other transactions never change what this transaction sees, even if it runs for a long time. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This fixed-at-start, consistent-view guarantee is exactly what protects a transaction from ever seeing a dirty read or a non-repeatable read caused by another transaction committing partway through.
2 / 5
During a design review, the team relies on snapshot isolation specifically so a long-running report query never sees a mix of old and newly-committed data from transactions that commit while the report is still running. Which capability does this provide?
Snapshot isolation here provides a stable, consistent view for the entire duration of the report, since the snapshot the report's transaction reads from is fixed at the exact moment that transaction started and never changes afterward, no matter how many other transactions commit while the report is still running. Reading the very latest committed data at every step instead would let the report mix old and newly-committed data together inconsistently as other transactions commit mid-report. This fixed-at-start view is exactly why snapshot isolation is the standard choice for a long-running report that needs a single, coherent picture of the data.
3 / 5
In a code review, a dev notices a transaction running under snapshot isolation reads an account balance, and later in that same transaction, computes a transfer amount and writes a new balance for a different account, where a second concurrent transaction is doing the mirror-image transfer between the same two accounts at the same time. What does this represent?
This is a write-skew risk, since snapshot isolation guarantees each transaction reads a consistent snapshot and prevents dirty or non-repeatable reads, but it doesn't by itself prevent two transactions from each independently making a decision, like a transfer amount, based on a snapshot that becomes inconsistent the moment both transactions actually commit their writes. A cache eviction policy is an unrelated concept about discarded cache entries. This is exactly the well-known limitation of snapshot isolation that a careful reviewer checks for whenever two transactions read overlapping data and then write to different, related records based on what they read.
4 / 5
An incident report shows two concurrent transfers between the same two accounts, each running under snapshot isolation and each individually checking that the source account had sufficient funds before transferring, together left one account with a negative balance after both committed. What practice would prevent this?
Adding an explicit serialization check, such as a constraint the database enforces at commit time, or moving this specific pair of transfers to a stricter isolation level like serializable, lets the database detect that the two transfers' snapshots became inconsistent with each other and reject one of them, which is exactly the fix for the negative balance described in this incident. Continuing to rely on snapshot isolation alone for this pair of transfers regardless of the write-skew risk is exactly what let both transfers proceed as if they were safe when together they weren't. This targeted, stricter-isolation fix is the standard remedy for exactly the write-skew pattern snapshot isolation alone can't prevent.
5 / 5
During a PR review, a teammate asks why the team doesn't just always use the strictest available isolation level everywhere instead of relying on snapshot isolation, given that snapshot isolation has this known write-skew limitation. What is the reasoning?
The strictest isolation level costs real throughput by serializing transactions that snapshot isolation could otherwise run fully concurrently without any actual conflict between them, so applying it everywhere would slow down the large majority of transactions that never actually run into a write-skew situation at all. Snapshot isolation is therefore used broadly for its strong performance and its protection against dirty and non-repeatable reads, with the stricter isolation level, or an explicit serialization check, reserved specifically for the narrower set of transactions genuinely at risk of write skew. The tradeoff is exactly why isolation level is chosen per workload rather than defaulting to the strictest option everywhere.