Write skew

Write skew occurs when concurrent transactions read the same data, independently decide that their changes satisfy a shared rule, and then update different rows. Both transactions can commit even though their combined changes violate the rule.

Minimal example

sql
SELECT COUNT(*) FROM orders WHERE rider_id = 9 AND status = 'PICKED_UP';

Learn this concept

Lesson 3.8 · Isolation levels and anomalies
Prerequisite conceptsIsolation level