Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

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.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.