CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ
Under snapshot isolation, x = 50 and y = 50 with the rule x + y ≥ 0. T1 reads x and y and, if x + y ≥ 100, sets x = x − 100. T2 concurrently reads x and y and, if x + y ≥ 100, sets y = y − 100. Both start before either commits. What is x + y after both finish?
- A. 0, because the second committer is rolled back
- B. -50
- C. 100, because both checks fail
- D. -100
Correct answer: D. -100
Each transaction reads the snapshot (50, 50), sees x + y = 100 and writes a different item, so first-committer-wins finds no write-write conflict and both commit: x = -50, y = -50, sum -100. This write skew is the classic SI anomaly.
More DBMS and SQL questions
- How many of these statements are correct? (i) Under multiversion timestamp ordering, a read request is never rejected. (ii) Thomas' write…
- During ARIES restart, the analysis pass rebuilds a dirty page table with entries P1 (recLSN 140), P2 (recLSN 95) and P3 (recLSN 210). The…
- Table Emp(eid, name, mgr, dept, sal) rows: (1, 'Aru', NULL, 'D1', 90), (2, 'Bin', 1, 'D1', 60), (3, 'Cy', 1, 'D2', 70), (4, 'Dev', 2…
- Table Emp(eid, name, mgr, dept, sal) rows: (1, 'Aru', NULL, 'D1', 90), (2, 'Bin', 1, 'D1', 60), (3, 'Cy', 1, 'D2', 70), (4, 'Dev', 2…
- Table Emp(eid, name, mgr, dept, sal) rows: (1, 'Aru', NULL, 'D1', 90), (2, 'Bin', 1, 'D1', 60), (3, 'Cy', 1, 'D2', 70), (4, 'Dev', 2…
- Table Emp(eid, name, mgr, dept, sal) rows: (1, 'Aru', NULL, 'D1', 90), (2, 'Bin', 1, 'D1', 60), (3, 'Cy', 1, 'D2', 70), (4, 'Dev', 2…