diff options
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/checkpointer.c | 42 | ||||
| -rw-r--r-- | src/backend/postmaster/postmaster.c | 4 |
2 files changed, 40 insertions, 6 deletions
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index 0b792d2b10..76cb25cd38 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -171,6 +171,7 @@ static void CheckArchiveTimeout(void); static bool IsCheckpointOnSchedule(double progress); static bool ImmediateCheckpointRequested(void); static bool CompactCheckpointerRequestQueue(void); +static void UpdateSharedMemoryConfig(void); /* Signal handlers */ @@ -351,8 +352,12 @@ CheckpointerMain(void) if (RecoveryInProgress()) ThisTimeLineID = GetRecoveryTargetTLI(); - /* Do this once before starting the loop, then just at SIGHUP time. */ - SyncRepUpdateSyncStandbysDefined(); + /* + * Ensure all shared memory values are set correctly for the config. + * Doing this here ensures no race conditions from other concurrent + * updaters. + */ + UpdateSharedMemoryConfig(); /* * Loop forever @@ -380,8 +385,19 @@ CheckpointerMain(void) { got_SIGHUP = false; ProcessConfigFile(PGC_SIGHUP); - /* update global shmem state for sync rep */ - SyncRepUpdateSyncStandbysDefined(); + + /* + * Checkpointer is the last process to shutdown, so we ask + * it to hold the keys for a range of other tasks required + * most of which have nothing to do with checkpointing at all. + * + * For various reasons, some config values can change + * dynamically so are the primary copy of them is held in + * shared memory to make sure all backends see the same value. + * We make Checkpointer responsible for updating the shared + * memory copy if the parameter setting changes because of SIGHUP. + */ + UpdateSharedMemoryConfig(); } if (checkpoint_requested) { @@ -1239,3 +1255,21 @@ AbsorbFsyncRequests(void) END_CRIT_SECTION(); } + +/* + * Update any shared memory configurations based on config parameters + */ +static void +UpdateSharedMemoryConfig(void) +{ + /* update global shmem state for sync rep */ + SyncRepUpdateSyncStandbysDefined(); + + /* + * If full_page_writes has been changed by SIGHUP, we update it + * in shared memory and write an XLOG_FPW_CHANGE record. + */ + UpdateFullPageWrites(); + + elog(DEBUG2, "checkpointer updated shared memory configuration values"); +} diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index ad0c17ac7a..9d242cbfcb 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3067,8 +3067,8 @@ PostmasterStateMachine(void) else { /* - * Terminate backup mode to avoid recovery after a clean fast - * shutdown. Since a backup can only be taken during normal + * Terminate exclusive backup mode to avoid recovery after a clean fast + * shutdown. Since an exclusive backup can only be taken during normal * running (and not, for example, while running under Hot Standby) * it only makes sense to do this if we reached normal running. If * we're still in recovery, the backup file is one we're |
