From 7f1c298e6a7fc1d2adf08a893ecb0c7951f4c038 Mon Sep 17 00:00:00 2001 From: Amul Sul Date: Thu, 23 Sep 2021 00:47:52 -0400 Subject: [PATCH v4 1/2] do the ControlFile timestamp setting in UpdateControlFile() --- src/backend/access/transam/xlog.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index e51a7a749da..e439148aa7e 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4942,12 +4942,13 @@ ReadControlFile(void) } /* - * Utility wrapper to update the control file. Note that the control - * file gets flushed. + * Utility wrapper to update the control file with update timestamp. Note that + * the control file gets flushed. */ void UpdateControlFile(void) { + ControlFile->time = (pg_time_t) time(NULL); update_controlfile(DataDir, ControlFile, true); } @@ -7149,7 +7150,7 @@ StartupXLOG(void) ControlFile->backupEndPoint = ControlFile->minRecoveryPoint; } } - ControlFile->time = (pg_time_t) time(NULL); + /* No need to hold ControlFileLock yet, we aren't up far enough */ UpdateControlFile(); @@ -8086,7 +8087,6 @@ StartupXLOG(void) */ LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); ControlFile->state = DB_IN_PRODUCTION; - ControlFile->time = (pg_time_t) time(NULL); SpinLockAcquire(&XLogCtl->info_lck); XLogCtl->SharedRecoveryState = RECOVERY_STATE_DONE; @@ -8955,7 +8955,6 @@ CreateCheckPoint(int flags) { LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); ControlFile->state = DB_SHUTDOWNING; - ControlFile->time = (pg_time_t) time(NULL); UpdateControlFile(); LWLockRelease(ControlFileLock); } @@ -9226,7 +9225,6 @@ CreateCheckPoint(int flags) ControlFile->state = DB_SHUTDOWNED; ControlFile->checkPoint = ProcLastRecPtr; ControlFile->checkPointCopy = checkPoint; - ControlFile->time = (pg_time_t) time(NULL); /* crash recovery should always recover to the end of WAL */ ControlFile->minRecoveryPoint = InvalidXLogRecPtr; ControlFile->minRecoveryPointTLI = 0; @@ -9354,7 +9352,6 @@ CreateEndOfRecoveryRecord(void) * changes to this point. */ LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); - ControlFile->time = (pg_time_t) time(NULL); ControlFile->minRecoveryPoint = recptr; ControlFile->minRecoveryPointTLI = ThisTimeLineID; UpdateControlFile(); @@ -9510,7 +9507,6 @@ CreateRestartPoint(int flags) { LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY; - ControlFile->time = (pg_time_t) time(NULL); UpdateControlFile(); LWLockRelease(ControlFileLock); } @@ -9571,7 +9567,6 @@ CreateRestartPoint(int flags) { ControlFile->checkPoint = lastCheckPointRecPtr; ControlFile->checkPointCopy = lastCheckPoint; - ControlFile->time = (pg_time_t) time(NULL); /* * Ensure minRecoveryPoint is past the checkpoint record. Normally, -- 2.18.0