aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/walsender.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-01-15 16:27:40 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-01-15 16:38:21 +0200
commit8f5d65e916796aaee1bf7dd66daf45ca56cd13be (patch)
treec9279279b9702d580cfd38c447e4ca63c797cff8 /src/backend/replication/walsender.c
parentfcd810c69adf11b6ec1cff35359be0dd27662eff (diff)
downloadpostgresql-8f5d65e916796aaee1bf7dd66daf45ca56cd13be.tar.gz
postgresql-8f5d65e916796aaee1bf7dd66daf45ca56cd13be.zip
Treat a WAL sender process that hasn't started streaming yet as a regular
backend, as far as the postmaster shutdown logic is concerned. That means, fast shutdown will wait for WAL sender processes to exit before signaling bgwriter to finish. This avoids race conditions between a base backup stopping or starting, and bgwriter writing the shutdown checkpoint WAL record. We don't want e.g the end-of-backup WAL record to be written after the shutdown checkpoint.
Diffstat (limited to 'src/backend/replication/walsender.c')
-rw-r--r--src/backend/replication/walsender.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index d078501814c..0ad6804e552 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -316,6 +316,16 @@ StartReplication(StartReplicationCmd * cmd)
StringInfoData buf;
/*
+ * Let postmaster know that we're streaming. Once we've declared us as
+ * a WAL sender process, postmaster will let us outlive the bgwriter and
+ * kill us last in the shutdown sequence, so we get a chance to stream
+ * all remaining WAL at shutdown, including the shutdown checkpoint.
+ * Note that there's no going back, and we mustn't write any WAL records
+ * after this.
+ */
+ MarkPostmasterChildWalSender();
+
+ /*
* Check that we're logging enough information in the WAL for
* log-shipping.
*