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

Commit 02ba5e3

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 28c5be4 commit 02ba5e3

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
@@ -922,6 +922,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
922922
int64 next_pageno;
923923
int next_entryno;
924924
MultiXactOffset *next_offptr;
925+
MultiXactOffset next_offset;
925926
LWLock *lock;
926927
LWLock *prevlock = NULL;
927928

@@ -1021,11 +1022,15 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
10211022
next_offptr += next_entryno;
10221023
}
10231024

1024-
if (*next_offptr != offset + nmembers)
1025+
/* Like in GetNewMultiXactId(), skip over offset 0 */
1026+
next_offset = offset + nmembers;
1027+
if (next_offset == 0)
1028+
next_offset = 1;
1029+
if (*next_offptr != next_offset)
10251030
{
10261031
/* should already be set to the correct value, or not at all */
10271032
Assert(*next_offptr == 0);
1028-
*next_offptr = offset + nmembers;
1033+
*next_offptr = next_offset;
10291034
MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
10301035
}
10311036

0 commit comments

Comments
 (0)