File tree 5 files changed +34
-6
lines changed
5 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -489,6 +489,25 @@ StartupCLOG(void)
489
489
*/
490
490
ClogCtl -> shared -> latest_page_number = pageno ;
491
491
492
+ LWLockRelease (CLogControlLock );
493
+ }
494
+
495
+ /*
496
+ * This must be called ONCE at the end of startup/recovery.
497
+ */
498
+ void
499
+ TrimCLOG (void )
500
+ {
501
+ TransactionId xid = ShmemVariableCache -> nextXid ;
502
+ int pageno = TransactionIdToPage (xid );
503
+
504
+ LWLockAcquire (CLogControlLock , LW_EXCLUSIVE );
505
+
506
+ /*
507
+ * Re-Initialize our idea of the latest page number.
508
+ */
509
+ ClogCtl -> shared -> latest_page_number = pageno ;
510
+
492
511
/*
493
512
* Zero out the remainder of the current clog page. Under normal
494
513
* circumstances it should be zeroes already, but it seems at least
Original file line number Diff line number Diff line change @@ -1567,7 +1567,7 @@ StartupMultiXact(void)
1567
1567
1568
1568
/*
1569
1569
* Zero out the remainder of the current members page. See notes in
1570
- * StartupCLOG () for motivation.
1570
+ * TrimCLOG () for motivation.
1571
1571
*/
1572
1572
entryno = MXOffsetToMemberEntry (offset );
1573
1573
if (entryno != 0 )
Original file line number Diff line number Diff line change @@ -6410,10 +6410,12 @@ StartupXLOG(void)
6410
6410
oldestActiveXID = checkPoint .oldestActiveXid ;
6411
6411
Assert (TransactionIdIsValid (oldestActiveXID ));
6412
6412
6413
- /* Startup commit log and related stuff */
6413
+ /*
6414
+ * Startup commit log and subtrans only. Other SLRUs are not
6415
+ * maintained during recovery and need not be started yet.
6416
+ */
6414
6417
StartupCLOG ();
6415
6418
StartupSUBTRANS (oldestActiveXID );
6416
- StartupMultiXact ();
6417
6419
6418
6420
/*
6419
6421
* If we're beginning at a shutdown checkpoint, we know that
@@ -6914,16 +6916,21 @@ StartupXLOG(void)
6914
6916
TransactionIdRetreat (ShmemVariableCache -> latestCompletedXid );
6915
6917
6916
6918
/*
6917
- * Start up the commit log and related stuff, too. In hot standby mode we
6918
- * did this already before WAL replay .
6919
+ * Start up the commit log and subtrans, if not already done for
6920
+ * hot standby .
6919
6921
*/
6920
6922
if (standbyState == STANDBY_DISABLED )
6921
6923
{
6922
6924
StartupCLOG ();
6923
6925
StartupSUBTRANS (oldestActiveXID );
6924
- StartupMultiXact ();
6925
6926
}
6926
6927
6928
+ /*
6929
+ * Perform end of recovery actions for any SLRUs that need it.
6930
+ */
6931
+ StartupMultiXact ();
6932
+ TrimCLOG ();
6933
+
6927
6934
/* Reload shared-memory state for prepared transactions */
6928
6935
RecoverPreparedTransactions ();
6929
6936
Original file line number Diff line number Diff line change 36
36
#include "pgstat.h"
37
37
#include "postmaster/autovacuum.h"
38
38
#include "postmaster/postmaster.h"
39
+ #include "postmaster/startup.h"
39
40
#include "replication/walsender.h"
40
41
#include "storage/bufmgr.h"
41
42
#include "storage/fd.h"
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