Skip to content

Commit 0176f8b

Browse files
committed
Fix incomplete backpatch of pg_multixact truncation changes to <= 9.2
The backpatch of a95335b to 9.2, 9.1 and 9.0 was incomplete, missing changes to xlog.c, primarily the call to TrimMultiXact(). Testing presumably didn't show a problem without these changes because TrimMultiXact() performs defense-in-depth work, which is not strictly necessary. It also missed moving StartupMultiXact() which would have been problematic if a restartpoing happened in exactly the wrong moment, causing a transient error. Andres Freund
1 parent 559eb85 commit 0176f8b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/backend/access/transam/xlog.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6308,6 +6308,12 @@ StartupXLOG(void)
63086308
XLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch;
63096309
XLogCtl->ckptXid = checkPoint.nextXid;
63106310

6311+
/*
6312+
* Startup MultiXact. We need to do this early because we need its state
6313+
* initialized because we attempt truncation during restartpoints.
6314+
*/
6315+
StartupMultiXact();
6316+
63116317
/*
63126318
* We must replay WAL entries using the same TimeLineID they were created
63136319
* under, so temporarily adopt the TLI indicated by the checkpoint (see
@@ -6453,8 +6459,9 @@ StartupXLOG(void)
64536459
ProcArrayInitRecovery(ShmemVariableCache->nextXid);
64546460

64556461
/*
6456-
* Startup commit log and subtrans only. Other SLRUs are not
6457-
* maintained during recovery and need not be started yet.
6462+
* Startup commit log and subtrans only. MultiXact has already
6463+
* been started up and other SLRUs are not maintained during
6464+
* recovery and need not be started yet.
64586465
*/
64596466
StartupCLOG();
64606467
StartupSUBTRANS(oldestActiveXID);
@@ -6966,7 +6973,7 @@ StartupXLOG(void)
69666973
/*
69676974
* Perform end of recovery actions for any SLRUs that need it.
69686975
*/
6969-
StartupMultiXact();
6976+
TrimMultiXact();
69706977
TrimCLOG();
69716978

69726979
/* Reload shared-memory state for prepared transactions */

src/include/access/multixact.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern Size MultiXactShmemSize(void);
5959
extern void MultiXactShmemInit(void);
6060
extern void BootStrapMultiXact(void);
6161
extern void StartupMultiXact(void);
62+
extern void TrimMultiXact(void);
6263
extern void ShutdownMultiXact(void);
6364
extern void MultiXactGetCheckptMulti(bool is_shutdown,
6465
MultiXactId *nextMulti,

0 commit comments

Comments
 (0)