Skip to content

Commit 4d936c3

Browse files
committed
Fix setting next multixid's offset at offset wraparound
In commit 789d653, 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
1 parent 31d3847 commit 4d936c3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/backend/access/transam/multixact.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
909909
int64next_pageno;
910910
intnext_entryno;
911911
MultiXactOffset *next_offptr;
912+
MultiXactOffset next_offset;
912913
LWLock *lock;
913914
LWLock *prevlock = NULL;
914915

@@ -976,11 +977,15 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
976977
next_offptr += next_entryno;
977978
}
978979

979-
if (*next_offptr != offset + nmembers)
980+
/* Like in GetNewMultiXactId(), skip over offset 0 */
981+
next_offset = offset + nmembers;
982+
if (next_offset == 0)
983+
next_offset = 1;
984+
if (*next_offptr != next_offset)
980985
{
981986
/* should already be set to the correct value, or not at all */
982987
Assert(*next_offptr == 0);
983-
*next_offptr = offset + nmembers;
988+
*next_offptr = next_offset;
984989
MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
985990
}
986991

0 commit comments

Comments
 (0)