aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2015-09-09 22:51:44 +0900
committerFujii Masao <fujii@postgresql.org>2015-09-09 22:52:35 +0900
commit2244c0652d2c20cd2557fb1940458b5f21cd48e0 (patch)
tree31e1714574feb3240152b373514a0d66e45d6a90 /src/backend/access/transam/xlog.c
parented476669e998b788770f07338aefd2594ff4cce9 (diff)
downloadpostgresql-2244c0652d2c20cd2557fb1940458b5f21cd48e0.tar.gz
postgresql-2244c0652d2c20cd2557fb1940458b5f21cd48e0.zip
Remove files signaling a standby promotion request at postmaster startup
This commit makes postmaster forcibly remove the files signaling a standby promotion request. Otherwise, the existence of those files can trigger a promotion too early, whether a user wants that or not. This removal of files is usually unnecessary because they can exist only during a few moments during a standby promotion. However there is a race condition: if pg_ctl promote is executed and creates the files during a promotion, the files can stay around even after the server is brought up to new master. Then, if new standby starts by using the backup taken from that master, the files can exist at the server startup and should be removed in order to avoid an unexpected promotion. Back-patch to 9.1 where promote signal file was introduced. Problem reported by Feike Steenbergen. Original patch by Michael Paquier, modified by me. Discussion: 20150528100705.4686.91426@wrigleys.postgresql.org
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index d8876f2f021..cc845d23e20 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -11337,6 +11337,16 @@ CheckForStandbyTrigger(void)
}
/*
+ * Remove the files signaling a standby promotion request.
+ */
+void
+RemovePromoteSignalFiles(void)
+{
+ unlink(PROMOTE_SIGNAL_FILE);
+ unlink(FALLBACK_PROMOTE_SIGNAL_FILE);
+}
+
+/*
* Check to see if a promote request has arrived. Should be
* called by postmaster after receiving SIGUSR1.
*/