Questions: Snapshot Isolation and Write Skew Anomalies

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Under snapshot isolation, two transactions T1 and T2 both run concurrently. T1 reads rows X and Y and writes row X; T2 reads rows X and Y and writes row Y. A constraint requires that X + Y > 0. Both T1 and T2 read X=5, Y=5 and each sets their respective row to -3. What happens?

ABoth commits succeed; the constraint X + Y > 0 is violated (write skew)
BOne transaction is aborted because both wrote to overlapping rows
CBoth transactions are aborted because SI detects the constraint violation
DT1 succeeds and T2 is aborted because T2 started later
Question 2 Multiple Choice

A developer wants to prevent write skew in a snapshot-isolated database without upgrading to SERIALIZABLE. What technique can they use at the application level?

AUse INSERT ... ON CONFLICT to deduplicate writes
BWrap all reads in SELECT FOR UPDATE to acquire write locks on read rows
CUse ROLLBACK SAVEPOINT after each read to create checkpoints
DSet the transaction isolation level to READ COMMITTED for the affected transactions
Question 3 True / False

Snapshot isolation's first-committer-wins rule prevents write skew anomalies.

TTrue
FFalse
Question 4 True / False

Write skew can occur even when two concurrent transactions never write to the same database row.

TTrue
FFalse
Question 5 Short Answer

Why does snapshot isolation fail to prevent write skew, even though it prevents lost updates, non-repeatable reads, and phantom reads?

Think about your answer, then reveal below.