public inbox for [email protected]help / color / mirror / Atom feed
pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage @ 2026-03-02 17:23 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Heikki Linnakangas @ 2026-03-02 17:23 UTC (permalink / raw) To: [email protected] Fix OldestMemberMXactId and OldestVisibleMXactId array usage Commit ab355e3a88 changed how the OldestMemberMXactId array is indexed. It's no longer indexed by synthetic dummyBackendId, but with ProcNumber. The PGPROC entries for prepared xacts come after auxiliary processes in the allProcs array, which rendered the calculation for MaxOldestSlot and the indexes into the array incorrect. (The OldestVisibleMXactId array is not used for prepared xacts, and thus never accessed with ProcNumber's greater than MaxBackends, so this only affects the OldestMemberMXactId array.) As a result, a prepared xact would store its value past the end of the OldestMemberMXactId array, overflowing into the OldestVisibleMXactId array. That could cause a transaction's row lock to appear invisible to other backends, or other such visibility issues. With a very small max_connections setting, the store could even go beyond the OldestVisibleMXactId array, stomping over the first element in the BufferDescriptor array. To fix, calculate the array sizes more precisely, and introduce helper functions to calculate the array indexes correctly. Author: Yura Sokolov <[email protected]> Reviewed-by: Sami Imseih <[email protected]> Reviewed-by: Chao Li <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected] Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ccae90abdbb61b43b4cb0625f8677f1ad079c61c Modified Files -------------- src/backend/access/transam/multixact.c | 131 +++++++++++++++++++++++---------- src/backend/access/transam/twophase.c | 7 +- src/backend/storage/lmgr/proc.c | 4 +- src/include/storage/proc.h | 1 + 4 files changed, 99 insertions(+), 44 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage @ 2026-03-02 17:23 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Heikki Linnakangas @ 2026-03-02 17:23 UTC (permalink / raw) To: [email protected] Fix OldestMemberMXactId and OldestVisibleMXactId array usage Commit ab355e3a88 changed how the OldestMemberMXactId array is indexed. It's no longer indexed by synthetic dummyBackendId, but with ProcNumber. The PGPROC entries for prepared xacts come after auxiliary processes in the allProcs array, which rendered the calculation for MaxOldestSlot and the indexes into the array incorrect. (The OldestVisibleMXactId array is not used for prepared xacts, and thus never accessed with ProcNumber's greater than MaxBackends, so this only affects the OldestMemberMXactId array.) As a result, a prepared xact would store its value past the end of the OldestMemberMXactId array, overflowing into the OldestVisibleMXactId array. That could cause a transaction's row lock to appear invisible to other backends, or other such visibility issues. With a very small max_connections setting, the store could even go beyond the OldestVisibleMXactId array, stomping over the first element in the BufferDescriptor array. To fix, calculate the array sizes more precisely, and introduce helper functions to calculate the array indexes correctly. Author: Yura Sokolov <[email protected]> Reviewed-by: Sami Imseih <[email protected]> Reviewed-by: Chao Li <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected] Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/dcd9c06a4203cb5489bf1bd54f0a27db5d33cac4 Modified Files -------------- src/backend/access/transam/multixact.c | 131 +++++++++++++++++++++++---------- src/backend/access/transam/twophase.c | 7 +- src/backend/storage/lmgr/proc.c | 4 +- src/include/storage/proc.h | 2 + 4 files changed, 100 insertions(+), 44 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage @ 2026-03-02 17:23 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Heikki Linnakangas @ 2026-03-02 17:23 UTC (permalink / raw) To: [email protected] Fix OldestMemberMXactId and OldestVisibleMXactId array usage Commit ab355e3a88 changed how the OldestMemberMXactId array is indexed. It's no longer indexed by synthetic dummyBackendId, but with ProcNumber. The PGPROC entries for prepared xacts come after auxiliary processes in the allProcs array, which rendered the calculation for MaxOldestSlot and the indexes into the array incorrect. (The OldestVisibleMXactId array is not used for prepared xacts, and thus never accessed with ProcNumber's greater than MaxBackends, so this only affects the OldestMemberMXactId array.) As a result, a prepared xact would store its value past the end of the OldestMemberMXactId array, overflowing into the OldestVisibleMXactId array. That could cause a transaction's row lock to appear invisible to other backends, or other such visibility issues. With a very small max_connections setting, the store could even go beyond the OldestVisibleMXactId array, stomping over the first element in the BufferDescriptor array. To fix, calculate the array sizes more precisely, and introduce helper functions to calculate the array indexes correctly. Author: Yura Sokolov <[email protected]> Reviewed-by: Sami Imseih <[email protected]> Reviewed-by: Chao Li <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected] Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0a50ef0943824d9eca83a5dd454cb18349069814 Modified Files -------------- src/backend/access/transam/multixact.c | 131 +++++++++++++++++++++++---------- src/backend/access/transam/twophase.c | 7 +- src/backend/storage/lmgr/proc.c | 4 +- src/include/storage/proc.h | 1 + 4 files changed, 99 insertions(+), 44 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-03-02 17:23 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-03-02 17:23 pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage Heikki Linnakangas <[email protected]> 2026-03-02 17:23 pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage Heikki Linnakangas <[email protected]> 2026-03-02 17:23 pgsql: Fix OldestMemberMXactId and OldestVisibleMXactId array usage Heikki Linnakangas <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox