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?

  1. A. 0, because the second committer is rolled back
  2. B. -50
  3. C. 100, because both checks fail
  4. 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

Exams that ask this topic