Loading lesson…
Level 1 · Apprentice0 XP
What a transaction promises, and the strange bugs when two of them run at the same time.
Step 1 / 6
ProblemBoth requests read 'seats left: 1', both decide it is fine, both write 'seats left: 0'. Two tickets are sold for one seat, and no error appears anywhere.
← → step
Before this: Reading query plans with EXPLAIN
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Reproduce the last-seat race: open two psql sessions, run BEGIN in both, read seats_left in both, then update and commit in both. Then repeat with SELECT … FOR UPDATE, and once more with a version column.