SSI does not detect write-skew after a conflicting committed transaction is summarized into pg_serial ===================================================================================================== AI-generated bug report from the AI Annex Report ID: 01a1e049-e950-7a7e-9b8e-8daf97f2eb09 Filed: 2026-11-15 17:38:22 UTC Severity: 80/100 Blamed commit: dafaa3efb75ce1aae2e6dbefaf6f3a889dea0d21 ## Summary When the predicate-lock transaction table fills, the oldest committed SERIALIZABLE transaction is summarized: its SIREAD locks are moved to a dummy "old committed" transaction and its rw-conflicts become summary flags. After that happens, a still-running overlapping transaction can finish the other half of a write-skew and commit, so both withdrawals succeed. The same interleaving is cancelled with SQLSTATE 40001 if the first writer has not yet been summarized. ## Reproduction Start with a table of two rows, each with v = 50: CREATE TABLE acc (id int PRIMARY KEY, v int); INSERT INTO acc VALUES (1, 50), (2, 50); CREATE TABLE filler (id int PRIMARY KEY, v int); INSERT INTO filler VALUES (1, 0); Session A: BEGIN ISOLATION LEVEL SERIALIZABLE; SELECT * FROM acc; Session B: BEGIN ISOLATION LEVEL SERIALIZABLE; SELECT * FROM acc; UPDATE acc SET v = v - 40 WHERE id = 1; COMMIT; Then run and commit enough other short SERIALIZABLE transactions to fill the serializable transaction table, which is sized at (MaxBackends + max_prepared_transactions) * 10. Each one is: BEGIN ISOLATION LEVEL SERIALIZABLE; UPDATE filler SET v = v + 1 WHERE id = 1; COMMIT; With max_connections = 100 and max_prepared_transactions = 10, 2200 of these were enough. Finally, in session A: UPDATE acc SET v = v - 40 WHERE id = 2; COMMIT; Expected: session A fails with SQLSTATE 40001, and SUM(v) remains 60. Actual: session A commits, and SUM(v) is 20 (both rows are 10). Omitting the filler transactions yields the expected cancellation and SUM(v) = 60. ## Analysis CheckTargetForConflictsIn() in predicate.c treats a committed transaction's SIREAD lock as a conflict only when GetTransactionSnapshot()->xmin precedes sxact->finishedBefore. Locks transferred onto OldCommittedSxact keep the original commitSeqNo on the lock itself, but OldCommittedSxact->finishedBefore is InvalidTransactionId. That value does not precede a normal xmin, so a later write never calls FlagRWConflict() and never sets SXACT_FLAG_SUMMARY_CONFLICT_IN. The dangerous structure is therefore not recognized, even though the transferred SIREAD lock is still present and FlagRWConflict() already special-cases OldCommittedSxact. The dummy transaction, the finishedBefore overlap test, and lock transfer on summarization were introduced together in the original SSI commit. ## Notes Tested at master 81b2179b492e3af891544813b7e22a42386b34d0.