write skew
Concurrent decisions update different rows and jointly violate an invariant.
Use this when Two on-call doctors each see the other available and both go off duty.
without the term
“Two doctors each see the other on duty and both sign off. Protect the rule that someone must stay.”
with the term · How do you ask a model for write skew?
Reproduce write skew for this cross-row invariant. Protect it and test two concurrent decisions, including required retries.
What is write skew?
Write skew occurs when transactions read a shared condition and write different records so that their combined result violates the condition. Snapshot isolation can allow it even without a same-row write conflict.
Why does write skew matter when vibe coding?
An agent can add row-version checks to separate rows and still leave the cross-row rule unprotected.
How do you do write skew?
Synchronize two decisions in a test. Use serializable execution with retries, a suitable constraint, or a shared lock boundary. Verify the invariant survives both attempted changes.
What goes wrong with write skew?
No lost update on a single row does not mean the transaction set is serializable.
Sources for this entry
- Berenson et al.: A Critique of ANSI SQL Isolation Levels
Definitions of read skew and write skew, and the distinction between snapshot isolation and serializability.
- PostgreSQL: Transaction isolation
Isolation-level behavior in PostgreSQL; snapshot isolation can still allow serialization anomalies.
Sources checked . Source checks do not establish human editorial approval. How we check content.