From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
Date: Fri, 20 Nov 2026 15:10:32 +0000
Message-ID: <E1xUQFz-00000000Wtz-0PKa@gemulon.postgresql.org> (raw)
Always prune dead members in MultiXactIdExpand, to fix assertion
MultiXactIdExpand() has an early return that returns the original
multixid, when the transaction is already a member. The early return
happened before pruning members that are no longer of interest, e.g.
aborted transactions.
The comment in MultiXactIdExpand() says that removing the dead members
is not merely an optimization but needed for freezing, so it was
surprising that they were not always removed. I don't see a live bug
with freezing though.
However, it tripped this assertion in heap_update(). When
heap_update() needs to temporarily lock the tuple before updating it,
it calls compute_new_xmax_infomask(), which calls MultiXactIdExpand(),
and then asserts that:
Assert(HEAP_XMAX_IS_LOCKED_ONLY(infomask_lock_old_tuple));
The assumption makes sense at first glance: we've checked that the
tuple is not being updated, and we computed the infomask for locking
it, so surely the infomask should not indicate any updaters. However,
if the xmax was previously a multixid which contained an updating
transaction that is now aborted, and our transaction was already a
member, MultiXactIdExpand() returned the original multixid with the
aborted updating member included.
To fix, make MultiXactIdExpand() remove dead members, even if the
original multixid already contains the transaction being added. That
makes the assertion valid again.
Reported-by: Jasper Smit <jbsmit@gmail.com>
Reported-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Reported-by: RekGRpth <rekgrpth@gmail.com>
Analyzed-by: Luc Vlaming Hummel <luc.vlaming@servicenow.com>
Discussion: https://www.postgresql.org/message-id/CAOG+RQ6ECiiFH7bb7e1M0bkd0whprp=T0u=rvARSaPOGrY-NDQ@mail.gmail...
Discussion: https://www.postgresql.org/message-id/CAPgh2mJhTo2yq_vLrT6OZPn54hDxJpDVu=9L7Ay_M5qogNFuTw@mail.gmail...
Backpatch-through: 15
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/c837e45eb822ab9f5e1c268e74bf3a3b99262c5a
Modified Files
--------------
src/backend/access/transam/multixact.c | 65 +++++++++++++++++++++-------------
src/test/regress/expected/combocid.out | 49 +++++++++++++++++++++++++
src/test/regress/sql/combocid.sql | 44 +++++++++++++++++++++++
3 files changed, 133 insertions(+), 25 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
In-Reply-To: <E1xUQFz-00000000Wtz-0PKa@gemulon.postgresql.org>
References: <E1xUQFz-00000000Wtz-0PKa@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox