File tree Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -490,6 +490,25 @@ StartupCLOG(void)
490
490
*/
491
491
ClogCtl -> shared -> latest_page_number = pageno ;
492
492
493
+ LWLockRelease (CLogControlLock );
494
+ }
495
+
496
+ /*
497
+ * This must be called ONCE at the end of startup/recovery.
498
+ */
499
+ void
500
+ TrimCLOG (void )
501
+ {
502
+ TransactionId xid = ShmemVariableCache -> nextXid ;
503
+ int pageno = TransactionIdToPage (xid );
504
+
505
+ LWLockAcquire (CLogControlLock , LW_EXCLUSIVE );
506
+
507
+ /*
508
+ * Re-Initialize our idea of the latest page number.
509
+ */
510
+ ClogCtl -> shared -> latest_page_number = pageno ;
511
+
493
512
/*
494
513
* Zero out the remainder of the current clog page. Under normal
495
514
* circumstances it should be zeroes already, but it seems at least
Original file line number Diff line number Diff line change @@ -1568,7 +1568,7 @@ StartupMultiXact(void)
1568
1568
1569
1569
/*
1570
1570
* Zero out the remainder of the current members page. See notes in
1571
- * StartupCLOG () for motivation.
1571
+ * TrimCLOG () for motivation.
1572
1572
*/
1573
1573
entryno = MXOffsetToMemberEntry (offset );
1574
1574
if (entryno != 0 )
Original file line number Diff line number Diff line change @@ -6384,10 +6384,12 @@ StartupXLOG(void)
6384
6384
oldestActiveXID = checkPoint .oldestActiveXid ;
6385
6385
Assert (TransactionIdIsValid (oldestActiveXID ));
6386
6386
6387
- /* Startup commit log and related stuff */
6387
+ /*
6388
+ * Startup commit log and subtrans only. Other SLRUs are not
6389
+ * maintained during recovery and need not be started yet.
6390
+ */
6388
6391
StartupCLOG ();
6389
6392
StartupSUBTRANS (oldestActiveXID );
6390
- StartupMultiXact ();
6391
6393
6392
6394
/*
6393
6395
* If we're beginning at a shutdown checkpoint, we know that
@@ -6876,16 +6878,21 @@ StartupXLOG(void)
6876
6878
TransactionIdRetreat (ShmemVariableCache -> latestCompletedXid );
6877
6879
6878
6880
/*
6879
- * Start up the commit log and related stuff, too. In hot standby mode we
6880
- * did this already before WAL replay .
6881
+ * Start up the commit log and subtrans, if not already done for
6882
+ * hot standby .
6881
6883
*/
6882
6884
if (standbyState == STANDBY_DISABLED )
6883
6885
{
6884
6886
StartupCLOG ();
6885
6887
StartupSUBTRANS (oldestActiveXID );
6886
- StartupMultiXact ();
6887
6888
}
6888
6889
6890
+ /*
6891
+ * Perform end of recovery actions for any SLRUs that need it.
6892
+ */
6893
+ StartupMultiXact ();
6894
+ TrimCLOG ();
6895
+
6889
6896
/* Reload shared-memory state for prepared transactions */
6890
6897
RecoverPreparedTransactions ();
6891
6898
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ extern Size CLOGShmemSize(void);
40
40
extern void CLOGShmemInit (void );
41
41
extern void BootStrapCLOG (void );
42
42
extern void StartupCLOG (void );
43
+ extern void TrimCLOG (void );
43
44
extern void ShutdownCLOG (void );
44
45
extern void CheckPointCLOG (void );
45
46
extern void ExtendCLOG (TransactionId newestXact );
You can’t perform that action at this time.
0 commit comments