pgsql: Fix race condition in committing a serializable transaction

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix race condition in committing a serializable transaction
Date: 2024-10-21 08:01:19
Message-ID: E1t2nLr-001jde-JK@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix race condition in committing a serializable transaction

The finished transaction list can contain XIDs that are older than the
serializable global xmin. It's a short-lived state;
ClearOldPredicateLocks() removes any such transactions from the list,
and it's called whenever the global xmin advances. But if another
backend calls SummarizeOldestCommittedSxact() in that window, it will
call SerialAdd() on an XID that's older than the global xmin, or if
there are no more transactions running, when global xmin is
invalid. That trips the assertion in SerialAdd().

Fixes bug #18658 reported by Andrew Bille. Thanks to Alexander Lakhin
for analysis. Backpatch to all versions.

Discussion: https://www.postgresql.org/message-id/18658-7dab125ec688c70b%40postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8e607a5a4be54f2d2bdfb7a53584d4b7ca1d2be3

Modified Files
--------------
src/backend/storage/lmgr/predicate.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2024-10-21 11:32:40 pgsql: Update outdated comment on WAL-logged locks with invalid XID
Previous Message Michael Paquier 2024-10-21 02:27:16 pgsql: Fix grammar of a comment in bufmgr.c