Both Doctors Walked
An on-call table must always have at least one doctor flagged on_call. Two doctors click off-call at the same moment. Each transaction runs at PostgreSQL REPEATABLE READ, reads SELECT count(*) FROM doctors WHERE on_call = true and sees 2, then updates its own row to false. Both commit with no error, and the shift ends with zero doctors on call. What went wrong?
Sign in to answer questions and track your progress
Sign In