mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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
This commit is contained in:
@ -11336,6 +11336,16 @@ CheckForStandbyTrigger(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
Reference in New Issue
Block a user