Skip to content

Commit faa0550

Browse files
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
1 parent 722bf70 commit faa0550

File tree

1 file changed

+6
-1
lines changed
  • src/backend/access/transam

1 file changed

+6
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9619,7 +9619,7 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
96199619
* five seconds like in the WAL file polling case below.
96209620
*/
96219621
if (CheckForStandbyTrigger())
9622-
goto triggered;
9622+
goto retry;
96239623

96249624
/*
96259625
* Wait for more WAL to arrive, or timeout to be reached
@@ -9886,6 +9886,10 @@ static bool
98869886
CheckForStandbyTrigger(void)
98879887
{
98889888
struct stat stat_buf;
9889+
static bool triggered = false;
9890+
9891+
if (triggered)
9892+
return true;
98899893

98909894
if (TriggerFile == NULL)
98919895
return false;
@@ -9896,6 +9900,7 @@ CheckForStandbyTrigger(void)
98969900
(errmsg("trigger file found: %s", TriggerFile)));
98979901
ShutdownWalRcv();
98989902
unlink(TriggerFile);
9903+
triggered = true;
98999904
return true;
99009905
}
99019906
return false;

0 commit comments

Comments
 (0)