postgres.git / summary / log / commit / refs

commit    4d689a17693ed65461b2f3a02c24c98f30d930d0
Author:   Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date:     Fri Dec 05 09:32:38 2025 +0000
First released in: 14.21, 15.16, 16.12, 17.8, 18.2

    Fix setting next multixid's offset at offset wraparound
    
    In commit 789d65364c, we started updating the next multixid's offset
    too when recording a multixid, so that it can always be used to
    calculate the number of members. I got it wrong at offset wraparound:
    we need to skip over offset 0. Fix that.
    
    Discussion: https://www.postgresql.org/message-id/d9996478-389a-4340-8735-bfad456b313c@iki.fi
    Backpatch-through: 14


src/backend/access/transam/multixact.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 6ce5202a078..a0ffa513e94 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -876,6 +876,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, int next_pageno; int next_entryno; MultiXactOffset *next_offptr; + MultiXactOffset next_offset; LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE); @@ -962,11 +963,15 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, next_offptr += next_entryno; } - if (*next_offptr != offset + nmembers) + /* Like in GetNewMultiXactId(), skip over offset 0 */ + next_offset = offset + nmembers; + if (next_offset == 0) + next_offset = 1; + if (*next_offptr != next_offset) { /* should already be set to the correct value, or not at all */ Assert(*next_offptr == 0); - *next_offptr = offset + nmembers; + *next_offptr = next_offset; MultiXactOffsetCtl->shared->page_dirty[slotno] = true; } [parent: b38feca1ce00]