pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
6+ messages / 1 participants
[nested] [flat]

* pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
@ 2026-11-20 15:10 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2026-11-20 15:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/67c10344ddbd1073f1b7aafb09d1b196a48735a1

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
@ 2026-11-20 15:10 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2026-11-20 15:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
@ 2026-11-20 15:10 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2026-11-20 15:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
@ 2026-11-20 15:10 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2026-11-20 15:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bd44d764ab1210c7f7fead92fdc2fbcd66ff84e4

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
@ 2026-11-20 15:10 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2026-11-20 15:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4f4dbb593ebadd3e0cb7d292cdb28d55a8679f03

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion
@ 2026-11-20 15:10 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2026-11-20 15:10 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a51ba655d2f2567a016458109a23d5b892eb2a5d

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-11-20 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 15:10 pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-11-20 15:10 pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-11-20 15:10 pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-11-20 15:10 pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-11-20 15:10 pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-11-20 15:10 pgsql: Always prune dead members in MultiXactIdExpand, to fix assertion Heikki Linnakangas <heikki.linnakangas@iki.fi>

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