Two doctors are on call. The rule: at least one must stay.
Both open the app at the same moment. Both see two doctors on duty. Both click "go off call."
Each transaction checked the rule. Each was correct. Nobody is on call.
This is write skew — and your database allowed it. Under the default isolation level in Postgres and SQL Server, reads inside a transaction don't lock what they read. You validated against a world that stopped existing mid-flight.
It never reproduces locally. One user, one thread, no overlap.
Three ways out:
→ SELECT ... FOR UPDATE — lock what you checked
→ SERIALIZABLE isolation — let the DB abort one
→ a constraint the database itself enforces
