pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix checks for aborted updating transaction in multixids
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/068c9aaec31bc3e73d156a49ba0c4128f067c010

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  30 ++++--
src/backend/access/transam/xact.c                  |   6 ++
src/test/modules/injection_points/Makefile         |   3 +-
.../expected/multixact-aborted-updater.out         |  84 ++++++++++++++++
src/test/modules/injection_points/meson.build      |   1 +
.../specs/multixact-aborted-updater.spec           | 107 +++++++++++++++++++++
src/test/recovery/meson.build                      |   1 +
.../recovery/t/060_multixact_crashed_updater.pl    |  75 +++++++++++++++
8 files changed, 297 insertions(+), 10 deletions(-)



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

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  30 ++++--
src/backend/access/transam/xact.c                  |   6 ++
src/test/modules/injection_points/Makefile         |   3 +-
.../expected/multixact-aborted-updater.out         |  84 ++++++++++++++++
src/test/modules/injection_points/meson.build      |   1 +
.../specs/multixact-aborted-updater.spec           | 107 +++++++++++++++++++++
src/test/recovery/meson.build                      |   1 +
.../recovery/t/060_multixact_crashed_updater.pl    |  75 +++++++++++++++
8 files changed, 297 insertions(+), 10 deletions(-)



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

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/94d53e9ec69fe30140cc0cf62b1f08f69b683347

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  30 ++++--
src/backend/access/transam/xact.c                  |   6 ++
src/test/modules/injection_points/Makefile         |   3 +-
.../expected/multixact-aborted-updater.out         |  84 ++++++++++++++++
src/test/modules/injection_points/meson.build      |   1 +
.../specs/multixact-aborted-updater.spec           | 107 +++++++++++++++++++++
src/test/recovery/meson.build                      |   1 +
.../recovery/t/060_multixact_crashed_updater.pl    |  75 +++++++++++++++
8 files changed, 297 insertions(+), 10 deletions(-)



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

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
REL_17_STABLE

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

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  30 ++++--
src/backend/access/transam/xact.c                  |   7 ++
src/test/modules/injection_points/Makefile         |   3 +-
.../expected/multixact-aborted-updater.out         |  84 ++++++++++++++++
src/test/modules/injection_points/meson.build      |   1 +
.../specs/multixact-aborted-updater.spec           | 107 +++++++++++++++++++++
src/test/recovery/meson.build                      |   1 +
.../recovery/t/060_multixact_crashed_updater.pl    |  75 +++++++++++++++
8 files changed, 298 insertions(+), 10 deletions(-)



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

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7cafc4abbdc7b63fa6bbc948347392560dd2451b

Modified Files
--------------
src/backend/access/heap/heapam.c                   | 30 ++++++---
src/test/recovery/meson.build                      |  1 +
.../recovery/t/060_multixact_crashed_updater.pl    | 75 ++++++++++++++++++++++
3 files changed, 97 insertions(+), 9 deletions(-)



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

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
REL_15_STABLE

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

Modified Files
--------------
src/backend/access/heap/heapam.c                   | 30 ++++++---
.../recovery/t/060_multixact_crashed_updater.pl    | 75 ++++++++++++++++++++++
2 files changed, 96 insertions(+), 9 deletions(-)



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

* pgsql: Fix checks for aborted updating transaction in multixids
@ 2026-10-15 08:43 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

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

Fix checks for aborted updating transaction in multixids

As mentioned in the comments in TransactionIdDidAbort() and in
heapam_visibility.c, the usual procedure for checking whether a
transaction aborted is to first call TransactionIdIsInProgress(), and
then !TransactionIdDidCommit().  A couple places didn't get the memo,
and used TransactionIdDidAbort() incorrectly.

In DoesMultiXactIdConflict(), the consequence was that if a
conflicting transaction was just aborting, and had already marked the
transaction as aborted in pg_xact, but had not yet removed itself from
ProcArray, the function would return false meaning that it does not
conflict, even though it was still considered as running by
TransactionIdIsInProgress().  That could cause trouble later.  One
known consequence is that if you then went ahead with updating the row
again and called MultiXactIdExpand(), MultiXactIdExpand() would see
both the old aborting transaction and the new updater as still
running, and throw an ERROR: new multixact has more than one updating
member.  The multixact-aborted-updater.spec included in this commit
exercises that scenario.

Another place that got this wrong was in heap_update(), where we check
if the updating transaction that was part of a multixid committed or
aborted.  Because it used TransactionIdDidAbort(), if the updating
transaction crashed, it was considered as committed and heap_update()
incorrectly returned TM_Updated indicating a conflict, even though the
row could be updated.  This would only happen if the multixid as whole
was still considered running, i.e. if the tuple was still locked by
other transactions while the updating transaction crashed.  That can
happen if the locker is a prepared transaction.  The included
060_multixact_crashed_updater.pl test tests that scenario.

Author: Chee Wooson <wuqi@vastdata.com.cn>
Tested-by: Lionel Hamayon <lionel.hamayon@evolution-digitale.fr>
Discussion: https://www.postgresql.org/message-id/5778D6297D3CCF21+202609151836512678486@vastdata.com.cn
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/623cdfa6493d11d47a0d2d31acda16f7fbd0af54

Modified Files
--------------
src/backend/access/heap/heapam.c                   | 30 ++++++---
.../recovery/t/060_multixact_crashed_updater.pl    | 75 ++++++++++++++++++++++
2 files changed, 96 insertions(+), 9 deletions(-)



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


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

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids Heikki Linnakangas <heikki.linnakangas@iki.fi>
2026-10-15 08:43 pgsql: Fix checks for aborted updating transaction in multixids 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