@@ -220,14 +220,6 @@ typedef struct MultiXactStateData
220220 MultiXactOffset oldestOffset ;
221221 bool oldestOffsetKnown ;
222222
223- /*
224- * True if a multixact truncation WAL record was replayed since the last
225- * checkpoint. This is used to trigger 'legacy truncations', i.e. truncate
226- * by looking at the data directory during WAL replay, when the primary is
227- * too old to generate truncation records.
228- */
229- bool sawTruncationInCkptCycle ;
230-
231223 /* support for anti-wraparound measures */
232224 MultiXactId multiVacLimit ;
233225 MultiXactId multiWarnLimit ;
@@ -2381,28 +2373,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
23812373 Assert (InRecovery );
23822374
23832375 if (MultiXactIdPrecedes (MultiXactState -> oldestMultiXactId , oldestMulti ))
2384- {
2385- /*
2386- * If there has been a truncation on the master, detected by seeing a
2387- * moving oldestMulti, without a corresponding truncation record, we
2388- * know that the primary is still running an older version of postgres
2389- * that doesn't yet log multixact truncations. So perform the
2390- * truncation ourselves.
2391- */
2392- if (!MultiXactState -> sawTruncationInCkptCycle )
2393- {
2394- ereport (LOG ,
2395- (errmsg ("performing legacy multixact truncation" ),
2396- errdetail ("Legacy truncations are sometimes performed when replaying WAL from an older primary." ),
2397- errhint ("Upgrade the primary, it is susceptible to data corruption." )));
2398- TruncateMultiXact (oldestMulti , oldestMultiDB , true);
2399- }
2400-
24012376 SetMultiXactIdLimit (oldestMulti , oldestMultiDB );
2402- }
2403-
2404- /* only looked at in the startup process, no lock necessary */
2405- MultiXactState -> sawTruncationInCkptCycle = false;
24062377}
24072378
24082379/*
@@ -2747,8 +2718,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
27472718 int slotno ;
27482719 MultiXactOffset * offptr ;
27492720
2750- /* XXX: Remove || AmStartupProcess() after WAL page magic bump */
2751- Assert (MultiXactState -> finishedStartup || AmStartupProcess ());
2721+ Assert (MultiXactState -> finishedStartup );
27522722
27532723 pageno = MultiXactIdToOffsetPage (multi );
27542724 entryno = MultiXactIdToOffsetEntry (multi );
@@ -2946,18 +2916,15 @@ PerformOffsetsTruncation(MultiXactId oldestMulti, MultiXactId newOldestMulti)
29462916 * Remove all MultiXactOffset and MultiXactMember segments before the oldest
29472917 * ones still of interest.
29482918 *
2949- * On a primary this is called as part of vacuum (via
2950- * vac_truncate_clog()). During recovery truncation is normally done by
2951- * replaying truncation WAL records instead of this routine; the exception is
2952- * when replaying records from an older primary that doesn't yet generate
2953- * truncation WAL records. In that case truncation is triggered by
2954- * MultiXactAdvanceOldest().
2919+ * This is only called on a primary as part of vacuum (via
2920+ * vac_truncate_clog()). During recovery truncation is done by replaying
2921+ * truncation WAL records logged here.
29552922 *
29562923 * newOldestMulti is the oldest currently required multixact, newOldestMultiDB
29572924 * is one of the databases preventing newOldestMulti from increasing.
29582925 */
29592926void
2960- TruncateMultiXact (MultiXactId newOldestMulti , Oid newOldestMultiDB , bool in_recovery )
2927+ TruncateMultiXact (MultiXactId newOldestMulti , Oid newOldestMultiDB )
29612928{
29622929 MultiXactId oldestMulti ;
29632930 MultiXactId nextMulti ;
@@ -2967,13 +2934,8 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB, bool in_reco
29672934 mxtruncinfo trunc ;
29682935 MultiXactId earliest ;
29692936
2970- /*
2971- * Need to allow being called in recovery for backwards compatibility,
2972- * when an updated standby replays WAL generated by a non-updated primary.
2973- */
2974- Assert (in_recovery || !RecoveryInProgress ());
2975- Assert (!in_recovery || AmStartupProcess ());
2976- Assert (in_recovery || MultiXactState -> finishedStartup );
2937+ Assert (!RecoveryInProgress ());
2938+ Assert (MultiXactState -> finishedStartup );
29772939
29782940 /*
29792941 * We can only allow one truncation to happen at once. Otherwise parts of
@@ -3086,22 +3048,15 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB, bool in_reco
30863048 * Prevent checkpoints from being scheduled concurrently. This is critical
30873049 * because otherwise a truncation record might not be replayed after a
30883050 * crash/basebackup, even though the state of the data directory would
3089- * require it. It's not possible (startup process doesn't have a PGXACT
3090- * entry), and not needed, to do this during recovery, when performing an
3091- * old-style truncation, though. There the entire scheduling depends on
3092- * the replayed WAL records which be the same after a possible crash.
3051+ * require it.
30933052 */
3094- if (!in_recovery )
3095- {
3096- Assert (!MyPgXact -> delayChkpt );
3097- MyPgXact -> delayChkpt = true;
3098- }
3053+ Assert (!MyPgXact -> delayChkpt );
3054+ MyPgXact -> delayChkpt = true;
30993055
31003056 /* WAL log truncation */
3101- if (!in_recovery )
3102- WriteMTruncateXlogRec (newOldestMultiDB ,
3103- oldestMulti , newOldestMulti ,
3104- oldestOffset , newOldestOffset );
3057+ WriteMTruncateXlogRec (newOldestMultiDB ,
3058+ oldestMulti , newOldestMulti ,
3059+ oldestOffset , newOldestOffset );
31053060
31063061 /*
31073062 * Update in-memory limits before performing the truncation, while inside
@@ -3122,8 +3077,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB, bool in_reco
31223077 /* Then offsets */
31233078 PerformOffsetsTruncation (oldestMulti , newOldestMulti );
31243079
3125- if (!in_recovery )
3126- MyPgXact -> delayChkpt = false;
3080+ MyPgXact -> delayChkpt = false;
31273081
31283082 END_CRIT_SECTION ();
31293083 LWLockRelease (MultiXactTruncationLock );
@@ -3371,9 +3325,6 @@ multixact_redo(XLogReaderState *record)
33713325 PerformOffsetsTruncation (xlrec .startTruncOff , xlrec .endTruncOff );
33723326
33733327 LWLockRelease (MultiXactTruncationLock );
3374-
3375- /* only looked at in the startup process, no lock necessary */
3376- MultiXactState -> sawTruncationInCkptCycle = true;
33773328 }
33783329 else
33793330 elog (PANIC , "multixact_redo: unknown op code %u" , info );
0 commit comments