🌐 AI搜索 & 代理 主页
Skip to content

Commit cad40ce

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 9d4f6d1 commit cad40ce

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
@@ -916,6 +916,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
916916
int64 next_pageno;
917917
int next_entryno;
918918
MultiXactOffset *next_offptr;
919+
MultiXactOffset next_offset;
919920
LWLock *lock;
920921
LWLock *prevlock = NULL;
921922

@@ -1015,11 +1016,15 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
10151016
next_offptr += next_entryno;
10161017
}
10171018

1018-
if (*next_offptr != offset + nmembers)
1019+
/* Like in GetNewMultiXactId(), skip over offset 0 */
1020+
next_offset = offset + nmembers;
1021+
if (next_offset == 0)
1022+
next_offset = 1;
1023+
if (*next_offptr != next_offset)
10191024
{
10201025
/* should already be set to the correct value, or not at all */
10211026
Assert(*next_offptr == 0);
1022-
*next_offptr = offset + nmembers;
1027+
*next_offptr = next_offset;
10231028
MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
10241029
}
10251030

0 commit comments

Comments
 (0)