Skip to content

Commit 4d689a1

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 b38feca commit 4d689a1

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
@@ -876,6 +876,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
876876
int next_pageno;
877877
int next_entryno;
878878
MultiXactOffset *next_offptr;
879+
MultiXactOffset next_offset;
879880

880881
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
881882

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

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

0 commit comments

Comments
 (0)