From: Heikki Linnakangas Date: Wed, 28 Jan 2009 08:50:53 +0000 (+0200) Subject: Remove the signaling to request hurrying a restartpoint. I don't see any X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=0af549e487e2e6dfe3bccd34803eca3519646cfa;p=users%2Fsimon%2Fpostgres.git Remove the signaling to request hurrying a restartpoint. I don't see any reason for that. Instead, make sure that the bgwriter processes a checkpoint request as such, and not as a restartoint request, if we've just ended recovery. --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 226e96953d..8c3083ae54 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6475,26 +6475,6 @@ exitRecovery(void) 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 diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index f9ab290823..428a440b03 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -426,13 +426,6 @@ BackgroundWriterMain(void) /* 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. @@ -450,6 +443,21 @@ BackgroundWriterMain(void) 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. @@ -1040,19 +1048,6 @@ RequestCheckpoint(int flags) } } -/* - * 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 diff --git a/src/include/postmaster/bgwriter.h b/src/include/postmaster/bgwriter.h index 35f24d68c2..d52d12ce21 100644 --- a/src/include/postmaster/bgwriter.h +++ b/src/include/postmaster/bgwriter.h @@ -26,7 +26,6 @@ extern double CheckPointCompletionTarget; extern void BackgroundWriterMain(void); extern void RequestCheckpoint(int flags); -extern void RequestRestartPointCompletion(void); extern void CheckpointWriteDelay(int flags, double progress);