Let The Write Be The Check
A wallet row holds balance = 100. Two withdrawal requests for 80 arrive at the same instant. Both run this single statement, in separate transactions, on PostgreSQL at the default READ COMMITTED isolation.
UPDATE wallets
SET balance = balance - 80
WHERE id = 7
AND balance >= 80
RETURNING balance;
What do the two statements return?
Sign in to answer questions and track your progress
Sign In