Skip to content

Commit 4896955

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 81416e1 commit 4896955

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
@@ -875,6 +875,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
875875
int next_pageno;
876876
int next_entryno;
877877
MultiXactOffset *next_offptr;
878+
MultiXactOffset next_offset;
878879

879880
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
880881

@@ -961,11 +962,15 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
961962
next_offptr += next_entryno;
962963
}
963964

964-
if (*next_offptr != offset + nmembers)
965+
/* Like in GetNewMultiXactId(), skip over offset 0 */
966+
next_offset = offset + nmembers;
967+
if (next_offset == 0)
968+
next_offset = 1;
969+
if (*next_offptr != next_offset)
965970
{
966971
/* should already be set to the correct value, or not at all */
967972
Assert(*next_offptr == 0);
968-
*next_offptr = offset + nmembers;
973+
*next_offptr = next_offset;
969974
MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
970975
}
971976

0 commit comments

Comments
 (0)