CS FundamentalsHardProduct-company placement

An account has balance 1000. Two sessions at READ COMMITTED each run SELECT bal (both read 1000 before either writes), then compute 1000 − 100 in the application and run UPDATE acct SET bal = 900, and commit. What is the final balance?

  1. A. 800
  2. B. 900
  3. C. 800, because the second UPDATE waits for the first one's row lock
  4. D. 1000

Correct answer: B. 900

Both write the absolute value 900 computed from the same old read, so one withdrawal is lost: the classic lost update. READ COMMITTED only stops reading uncommitted data; to prevent it use UPDATE ... SET bal = bal − 100, SELECT ... FOR UPDATE or a stronger isolation level.

More DBMS and SQL questions

Exams that ask this topic