diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2012-01-25 18:02:04 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2012-01-25 18:02:04 +0000 |
commit | 8366c7803ec3d0591cf2d1226fea1fee947d56c3 (patch) | |
tree | 6cdd97e2f9352127db470507f4e650fde0ad6f86 /src/backend/postmaster/checkpointer.c | |
parent | 74ab96a45ef6259aa6a86a781580edea8488511a (diff) | |
download | postgresql-8366c7803ec3d0591cf2d1226fea1fee947d56c3.tar.gz postgresql-8366c7803ec3d0591cf2d1226fea1fee947d56c3.zip |
Allow pg_basebackup from standby node with safety checking.
Base backup follows recommended procedure, plus goes to great
lengths to ensure that partial page writes are avoided.
Jun Ishizuka and Fujii Masao, with minor modifications
Diffstat (limited to 'src/backend/postmaster/checkpointer.c')
-rw-r--r-- | src/backend/postmaster/checkpointer.c | 42 |
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"); +} |