ConcurrencyAdvanced

What is write skew?

“Explain write skew and why snapshot isolation does not prevent it.”

What this tests

  • The one anomaly snapshot isolation misses

Answers by level

Read the beginner answer first and notice what is missing.

Two transactions read overlapping data, each check a condition that is still true, and each write a different row in a way that jointly breaks the invariant. Two doctors both see two on call, both go off call, nobody is on call. No row is written twice, so there is no write conflict for snapshot isolation to detect.

Only Serializable — which tracks read/write dependencies — catches it, or you make the writes collide by locking a row that represents the shared condition.

Green flags · Red flags

Strong green flag · Explains why row locks and Repeatable Read both miss it.
Green flags
  • Different rows, shared condition
  • Knows only Serializable catches it
  • Offers the lock-a-representative-row alternative
Red flags
  • Thinks Repeatable Read prevents it
  • Confuses it with lost update

Follow-up questions

F1
Cheaper alternative to Serializable for the on-call example?

Scenario

A rule requires at least one admin. Two admins simultaneously demote themselves and both succeed. Which anomaly, and two fixes?

Learn this topic