diff options
| author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-12-05 11:32:38 +0200 |
|---|---|---|
| committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2025-12-05 11:32:38 +0200 |
| commit | 4d936c3fff1ac8dead2cc240ba3da2ed6337257c (patch) | |
| tree | 13ce9607efd09677b19b33c8dff60aeb9c172ba5 /src | |
| parent | 31d3847a37bec060fb4177b2fc6c0fdfc7a08011 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/access/transam/multixact.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 27f02faec80..8ed3fd9d071 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -909,6 +909,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, int64 next_pageno; int next_entryno; MultiXactOffset *next_offptr; + MultiXactOffset next_offset; LWLock *lock; LWLock *prevlock = NULL; @@ -976,11 +977,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; } |
