In a Django service, two concurrent requests are charging money from the same balance, and sometimes the balance goes negative or one of the charges gets lost. Why does this happen, and how would you fix it?
~4 min by voice
How to approach it
This checks whether the candidate understands the nature of the read-modify-write race (lost update) and why transaction.atomic doesn't cure it, and whether they can choose a suitable protection mechanism (pessimistic or optimistic locking, an atomic update, database constraints) while accounting for the related risks: deadlocks, retries and idempotency.
The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.