diff options
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 91f62368fe0..3d7d3bc9627 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5196,6 +5196,14 @@ StartupXLOG(void) XLogCtl->ckptXid = checkPoint.nextXid; /* + * Startup MultiXact. We need to do this early for two reasons: one + * is that we might try to access multixacts when we do tuple freezing, + * and the other is we need its state initialized because we attempt + * truncation during restartpoints. + */ + StartupMultiXact(); + + /* * Initialize unlogged LSN. On a clean shutdown, it's restored from the * control file. On recovery, all unlogged relations are blown away, so * the unlogged LSN counter can be reset too. @@ -5395,8 +5403,9 @@ StartupXLOG(void) ProcArrayInitRecovery(ShmemVariableCache->nextXid); /* - * Startup commit log and subtrans only. Other SLRUs are not - * maintained during recovery and need not be started yet. + * Startup commit log and subtrans only. MultiXact has already + * been started up and other SLRUs are not maintained during + * recovery and need not be started yet. */ StartupCLOG(); StartupSUBTRANS(oldestActiveXID); @@ -6061,8 +6070,8 @@ StartupXLOG(void) /* * Perform end of recovery actions for any SLRUs that need it. */ - StartupMultiXact(); TrimCLOG(); + TrimMultiXact(); /* Reload shared-memory state for prepared transactions */ RecoverPreparedTransactions(); @@ -7460,6 +7469,21 @@ CreateRestartPoint(int flags) LWLockRelease(ControlFileLock); /* + * Due to an historical accident multixact truncations are not WAL-logged, + * but just performed everytime the mxact horizon is increased. So, unless + * we explicitly execute truncations on a standby it will never clean out + * /pg_multixact which obviously is bad, both because it uses space and + * because we can wrap around into pre-existing data... + * + * We can only do the truncation here, after the UpdateControlFile() + * above, because we've now safely established a restart point, that + * guarantees we will not need need to access those multis. + * + * It's probably worth improving this. + */ + TruncateMultiXact(lastCheckPoint.oldestMulti); + + /* * Delete old log files (those no longer needed even for previous * checkpoint/restartpoint) to prevent the disk holding the xlog from * growing full. |