aboutsummaryrefslogtreecommitdiff
path: root/src/backend/postmaster/checkpointer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/postmaster/checkpointer.c')
-rw-r--r--src/backend/postmaster/checkpointer.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 0b792d2b105..76cb25cd382 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");
+}