Prevent a Lost Update
Two sessions withdraw 100 from the same account at the same time. Write the transaction that reads the balance and updates it safely so that one withdrawal cannot overwrite the other.
Table schema
Accounts(id INT PRIMARY KEY, balance INT)Sample data
Account (1, 500); two concurrent sessions each withdraw 100
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.