| From: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion |
| Date: | 2026-11-20 15:10:32 |
| Message-ID: | E1xUQFz-00000000Wtx-0Iqi@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Reported-by: Lionel Hamayon <lionel(dot)hamayon(at)evolution-digitale(dot)fr>
Reported-by: RekGRpth <rekgrpth(at)gmail(dot)com>
Analyzed-by: Luc Vlaming Hummel <luc(dot)vlaming(at)servicenow(dot)com>
Discussion: https://www.postgresql.org/message-id/CAOG+RQ6ECiiFH7bb7e1M0bkd0whprp=T0u=rvARSaPOGrY-NDQ@mail.gmail.com
Discussion: https://www.postgresql.org/message-id/CAPgh2mJhTo2yq_vLrT6OZPn54hDxJpDVu=9L7Ay_M5qogNFuTw@mail.gmail.com
Backpatch-through: 15
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/64104ae87a7917a8840c672b00eeb263fc8a05fc
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-11-20 16:52:33 | pgsql: Fix SEARCH/CYCLE when the recursive term has resjunk columns. |
| Previous Message | Fujii Masao | 2026-11-20 11:44:58 | pgsql: pg_rewind: Fix recovery delays at WAL page boundaries |