Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e60581f

Browse files
committed
Fix pg_upgrade's multixact handling (again)
We need to create the pg_multixact/offsets file deleted by pg_upgrade much earlier than we originally were: it was in TrimMultiXact(), which runs after we exit recovery, but it actually needs to run earlier than the first call to SetMultiXactIdLimit (before recovery), because that routine already wants to read the first offset segment. Per pg_upgrade trouble report from Jeff Janes. While at it, silence a compiler warning about a pointless assert that an unsigned variable was being tested non-negative. This was a signed constant in Thomas Munro's patch which I changed to unsigned before commit. Pointed out by Andres Freund.
1 parent cf0d888 commit e60581f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/backend/access/transam/multixact.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,14 +1989,6 @@ TrimMultiXact(void)
19891989
int entryno;
19901990
int flagsoff;
19911991

1992-
/*
1993-
* During a binary upgrade, make sure that the offsets SLRU is large
1994-
* enough to contain the next value that would be created. It's fine to do
1995-
* this here and not in StartupMultiXact() since binary upgrades should
1996-
* never need crash recovery.
1997-
*/
1998-
if (IsBinaryUpgrade)
1999-
MaybeExtendOffsetSlru();
20001992

20011993
/* Clean up offsets state */
20021994
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
@@ -2137,6 +2129,20 @@ MultiXactSetNextMXact(MultiXactId nextMulti,
21372129
MultiXactState->nextMXact = nextMulti;
21382130
MultiXactState->nextOffset = nextMultiOffset;
21392131
LWLockRelease(MultiXactGenLock);
2132+
2133+
/*
2134+
* During a binary upgrade, make sure that the offsets SLRU is large
2135+
* enough to contain the next value that would be created.
2136+
*
2137+
* We need to do this pretty early during the first startup in binary
2138+
* upgrade mode: before StartupMultiXact() in fact, because this routine is
2139+
* called even before that by StartupXLOG(). And we can't do it earlier
2140+
* than at this point, because during that first call of this routine we
2141+
* determine the MultiXactState->nextMXact value that MaybeExtendOffsetSlru
2142+
* needs.
2143+
*/
2144+
if (IsBinaryUpgrade)
2145+
MaybeExtendOffsetSlru();
21402146
}
21412147

21422148
/*
@@ -2532,8 +2538,6 @@ MultiXactOffsetWouldWrap(MultiXactOffset boundary, MultiXactOffset start,
25322538
{
25332539
MultiXactOffset finish;
25342540

2535-
Assert(distance >= 0);
2536-
25372541
/*
25382542
* Note that offset number 0 is not used (see GetMultiXactIdMembers), so
25392543
* if the addition wraps around the UINT_MAX boundary, skip that value.

0 commit comments

Comments
 (0)