diff options
| author | Tom Lane | 2009-06-26 20:29:04 +0000 |
|---|---|---|
| committer | Tom Lane | 2009-06-26 20:29:04 +0000 |
| commit | 2de48a83e65911ec8fc71fc87d75a75f5a3d6090 (patch) | |
| tree | 3d1bcdc353f59e54e323185cf5456ba0dbc8c5c8 /src/backend/postmaster/bgwriter.c | |
| parent | a6667d96c5e4aca92612295d549541146dd6e74a (diff) | |
Cleanup and code review for the patch that made bgwriter active during
archive recovery. Invent a separate state variable and inquiry function
for XLogInsertAllowed() to clarify some tests and make the management of
writing the end-of-recovery checkpoint less klugy. Fix several places
that were incorrectly testing InRecovery when they should be looking at
RecoveryInProgress or XLogInsertAllowed (because they will now be executed
in the bgwriter not startup process). Clarify handling of bad LSNs passed
to XLogFlush during recovery. Use a spinlock for setting/testing
SharedRecoveryInProgress. Improve quite a lot of comments.
Heikki and Tom
Diffstat (limited to 'src/backend/postmaster/bgwriter.c')
| -rw-r--r-- | src/backend/postmaster/bgwriter.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index b5fd31532e6..831ea9478a7 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -19,7 +19,8 @@ * condition.) * * The bgwriter is started by the postmaster as soon as the startup subprocess - * finishes. It remains alive until the postmaster commands it to terminate. + * finishes, or as soon as recovery begins if we are doing archive recovery. + * It remains alive until the postmaster commands it to terminate. * Normal termination is by SIGUSR2, which instructs the bgwriter to execute * a shutdown checkpoint and then exit(0). (All backends must be stopped * before SIGUSR2 is issued!) Emergency termination is by SIGQUIT; like any @@ -37,7 +38,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.61 2009/06/25 21:36:00 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.62 2009/06/26 20:29:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -902,11 +903,11 @@ BgWriterShmemInit(void) * * flags is a bitwise OR of the following: * CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown. - * CHECKPOINT_END_OF_RECOVERY: checkpoint is to finish WAL recovery. + * CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery. * CHECKPOINT_IMMEDIATE: finish the checkpoint ASAP, * ignoring checkpoint_completion_target parameter. * CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occured - * since the last one (implied by CHECKPOINT_IS_SHUTDOWN and + * since the last one (implied by CHECKPOINT_IS_SHUTDOWN or * CHECKPOINT_END_OF_RECOVERY). * CHECKPOINT_WAIT: wait for completion before returning (otherwise, * just signal bgwriter to do it, and return). |
