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 @@ -6067,10 +6067,12 @@ StartupXLOG(void)
6067
6067
oldestActiveXID = checkPoint .oldestActiveXid ;
6068
6068
Assert (TransactionIdIsValid (oldestActiveXID ));
6069
6069
6070
- /* Startup commit log and related stuff */
6070
+ /*
6071
+ * Startup commit log and subtrans only. Other SLRUs are not
6072
+ * maintained during recovery and need not be started yet.
6073
+ */
6071
6074
StartupCLOG ();
6072
6075
StartupSUBTRANS (oldestActiveXID );
6073
- StartupMultiXact ();
6074
6076
6075
6077
/*
6076
6078
* If we're beginning at a shutdown checkpoint, we know that
@@ -6530,16 +6532,21 @@ StartupXLOG(void)
6530
6532
TransactionIdRetreat (ShmemVariableCache -> latestCompletedXid );
6531
6533
6532
6534
/*
6533
- * Start up the commit log and related stuff, too. In hot standby mode we
6534
- * did this already before WAL replay .
6535
+ * Start up the commit log and subtrans, if not already done for
6536
+ * hot standby .
6535
6537
*/
6536
6538
if (standbyState == STANDBY_DISABLED )
6537
6539
{
6538
6540
StartupCLOG ();
6539
6541
StartupSUBTRANS (oldestActiveXID );
6540
- StartupMultiXact ();
6541
6542
}
6542
6543
6544
+ /*
6545
+ * Perform end of recovery actions for any SLRUs that need it.
6546
+ */
6547
+ StartupMultiXact ();
6548
+ TrimCLOG ();
6549
+
6543
6550
/* Reload shared-memory state for prepared transactions */
6544
6551
RecoverPreparedTransactions ();
6545
6552
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