Code QuizAdvanced

MVCC tuple visibility via xmin/xmax and the system snapshot

A transaction's snapshot is fixed at the start under REPEATABLE READ, so later-committed rows stay invisible even though their xmin exists.

Codesql
-- Session A: tally orders before and after Session B inserts
BEGIN ISOLATION LEVEL REPEATABLE READ;

SELECT count(*) FROM orders;   -- returns 5

-- (meanwhile Session B runs:)
--   INSERT INTO orders (id) VALUES (99);
--   COMMIT;

SELECT count(*) FROM orders;   -- developer expects 6

COMMIT;

The developer expects the second count to be 6 after Session B commits a new row, but it still returns 5. What is the bug?