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?
- A. 800
- B. 900
- C. 800, because the second UPDATE waits for the first one's row lock
- 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
- Two transactions each read row X under a shared lock and later want to update it, so each requests an upgrade to an exclusive lock. What…
- After ARIES analysis the dirty page table holds P1 (recLSN 40), P2 (recLSN 25) and P3 (recLSN 60); the last checkpoint began at LSN 30…
- A DBMS uses deferred database modification: no change reaches the database before its transaction commits (NO-STEAL), but committed…
- A B+ tree stores 1,000,000 keys. Each internal node has at most 50 children (at least 25, except the root, which needs at least 2), and…
- R occupies 1000 blocks and S 500 blocks; 50 buffer blocks are available. Ignoring the cost of writing the result, what does a Grace hash…
- A table has 1,000,000 rows stored 20 per block. An unclustered B+ tree index fetches each matching row with one random block read (ignore…