aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2011-02-08 14:38:02 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2011-02-08 14:38:02 +0000
commitfaa0550572583f51dba25611ab0f1d1c31de559b (patch)
treef8ec9e20f7fb9698089f1044dc4714b74daa704a
parent722bf7017bbe796decc79c1fde03e7a83dae9ada (diff)
downloadpostgresql-faa0550572583f51dba25611ab0f1d1c31de559b.tar.gz
postgresql-faa0550572583f51dba25611ab0f1d1c31de559b.zip
Remove rare corner case for data loss when triggering standby server.
If the standby was streaming when trigger file arrives, check also in the archive for additional WAL files. This is a corner case since it is unlikely that we would trigger a failover while the master is still available and sending data to standby, while at the same time running in archive mode and also while the streaming standby has fallen behind archive. Someone would eventually be unlucky; we must plug all gaps however small. Fujii Masao
-rw-r--r--src/backend/access/transam/xlog.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 25c7e062343..1a3eed212ff 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -9619,7 +9619,7 @@ retry:
* five seconds like in the WAL file polling case below.
*/
if (CheckForStandbyTrigger())
- goto triggered;
+ goto retry;
/*
* Wait for more WAL to arrive, or timeout to be reached
@@ -9886,6 +9886,10 @@ static bool
CheckForStandbyTrigger(void)
{
struct stat stat_buf;
+ static bool triggered = false;
+
+ if (triggered)
+ return true;
if (TriggerFile == NULL)
return false;
@@ -9896,6 +9900,7 @@ CheckForStandbyTrigger(void)
(errmsg("trigger file found: %s", TriggerFile)));
ShutdownWalRcv();
unlink(TriggerFile);
+ triggered = true;
return true;
}
return false;