{
sigjmp_buf local_sigjmp_buf;
MemoryContext bgwriter_context;
- bool BgWriterRecoveryMode = true;
BgWriterShmem->bgwriter_pid = MyProcPid;
am_bg_writer = true;
flags |= CHECKPOINT_CAUSE_TIME;
}
- /*
- * Check if we've exited recovery. We do this after determining
- * whether to perform a checkpoint or not, to be sure that we
- * perform a real checkpoint and not a restartpoint, if someone
- * requested a checkpoint immediately after exiting recovery. And
- * we must have the right TimeLineID when we perform a checkpoint;
- * IsRecoveryProcessingMode() initializes that as a side-effect.
- */
- if (BgWriterRecoveryMode && !IsRecoveryProcessingMode())
- {
- elog(DEBUG1, "bgwriter changing from recovery to normal mode");
- BgWriterRecoveryMode = false;
- }
-
/*
* Do a checkpoint if requested, otherwise do one cycle of
* dirty-buffer writing.
if (do_checkpoint)
{
bool ckpt_performed = false;
+ bool do_restartpoint;
/* use volatile pointer to prevent code rearrangement */
volatile BgWriterShmemStruct *bgs = BgWriterShmem;
+ /*
+ * Check if we should perform a checkpoint or a restartpoint.
+ * As a side-effect, IsRecoveryProcessingMode() initializes
+ * TimeLineID if it's not set yet.
+ */
+ do_restartpoint = IsRecoveryProcessingMode();
+
/*
* Atomically fetch the request flags to figure out what kind of a
* checkpoint we should perform, and increase the started-counter
* implementation will not generate warnings caused by
* CheckPointTimeout < CheckPointWarning.
*/
- if (!BgWriterRecoveryMode &&
+ if (!do_restartpoint &&
(flags & CHECKPOINT_CAUSE_XLOG) &&
elapsed_secs < CheckPointWarning)
ereport(LOG,
* Initialize bgwriter-private variables used during checkpoint.
*/
ckpt_active = true;
- if (!BgWriterRecoveryMode)
+ if (!do_restartpoint)
ckpt_start_recptr = GetInsertRecPtr();
ckpt_start_time = now;
ckpt_cached_elapsed = 0;
/*
* Do the checkpoint.
*/
- if (!BgWriterRecoveryMode)
+ if (!do_restartpoint)
{
CreateCheckPoint(flags);
ckpt_performed = true;