rdata.len = sizeof(TimeLineID);
rdata.next = NULL;
- /*
- * If a restartpoint is in progress, we will not be able to successfully
- * acquire CheckpointLock. If bgwriter is still in progress then send
- * a second signal to nudge bgwriter to go faster so we can avoid delay.
- * Then wait for lock, so we know the restartpoint has completed. We do
- * this because we don't want to interrupt the restartpoint half way
- * through, which might leave us in a mess and we want to be robust. We're
- * going to checkpoint soon anyway, so not it's not wasted effort.
- */
- if (LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
- LWLockRelease(CheckpointLock);
- else
- {
- RequestRestartPointCompletion();
- ereport(LOG,
- (errmsg("startup process waiting for restartpoint to complete")));
- LWLockAcquire(CheckpointLock, LW_EXCLUSIVE);
- LWLockRelease(CheckpointLock);
- }
-
/*
* This is the only type of WAL message that can be inserted during
* recovery. This ensures that we don't allow others to get access
/* Normal exit from the bgwriter is here */
proc_exit(0); /* done */
}
- if (BgWriterRecoveryMode && !IsRecoveryProcessingMode())
- {
- elog(DEBUG1, "bgwriter changing from recovery to normal mode");
-
- InitXLOGAccess();
- BgWriterRecoveryMode = false;
- }
/*
* Force a checkpoint if too much time has elapsed since the last one.
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
+ * (like the startup process!) requested a checkpoint immediately
+ * after exiting recovery.
+ */
+ if (BgWriterRecoveryMode && !IsRecoveryProcessingMode())
+ {
+ elog(DEBUG1, "bgwriter changing from recovery to normal mode");
+
+ InitXLOGAccess();
+ BgWriterRecoveryMode = false;
+ }
+
/*
* Do a checkpoint if requested, otherwise do one cycle of
* dirty-buffer writing.
}
}
-/*
- * Sends another checkpoint request signal to bgwriter, which causes it
- * to avoid smoothed writes and continue processing as if it had been
- * called with CHECKPOINT_IMMEDIATE. This is used at the end of recovery.
- */
-void
-RequestRestartPointCompletion(void)
-{
- if (BgWriterShmem->bgwriter_pid != 0 &&
- kill(BgWriterShmem->bgwriter_pid, SIGINT) != 0)
- elog(LOG, "could not signal for restartpoint immediate: %m");
-}
-
/*
* ForwardFsyncRequest
* Forward a file-fsync request from a backend to the bgwriter