Level 1 · Apprentice0 XP
How many transactions run at once, and how to avoid lost updates and deadlocks.
Step 1 / 6
ProblemIn 'Transactions and isolation levels', two customers bought the last seat at the same moment. This lesson opens the box: how PostgreSQL lets many transactions run at once, and what really happens when one of them locks a row.
← → step
Before this: Transactions and isolation levels
🛠️ 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 double-booking race with two psql sessions, fix it with FOR UPDATE and then with a conditional UPDATE. Build a jobs table worked by three workers with FOR UPDATE SKIP LOCKED.