IT lexicon › Database › Write skew

Write skew

Database På svenska → Updated: 2026-05-28

Concurrency anomaly: two transactions both read overlapping data, both update based on what they saw, end-state is invalid despite both being isolated. Snapshot isolation allows this; SERIALIZABLE blocks it.

Classic example: hospital rule "at least one doctor on-call". Tx1: doctor A checks if they can take leave — count(on_call) = 2 → yes. Tx2: doctor B same — count = 2 → yes. Both update on_call = false. Result: 0 doctors on-call. Both saw state with 2 doctors, decisions isolated, committed atomically — but the combined result is invalid. Defense: SERIALIZABLE isolation (SSI), explicit row locks (FOR UPDATE), application-level constraint validation. PostgreSQL SERIALIZABLE detects write skew and aborts a transaction.

← Back to the lexicon