Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96f6a0c

Browse files
committed
Remove files signaling a standby promotion request at postmaster startup
This commit makes postmaster forcibly remove the files signalinga standby promotion request. Otherwise, the existence of those filescan trigger a promotion too early, whether a user wants that or not.This removal of files is usually unnecessary because they can existonly during a few moments during a standby promotion. Howeverthere is a race condition: if pg_ctl promote is executed and createsthe files during a promotion, the files can stay around even afterthe server is brought up to new master. Then, if new standby startsby using the backup taken from that master, the files can existat the server startup and should be removed in order to avoidan 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
1 parentc3e0ddd commit96f6a0c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11587,6 +11587,16 @@ CheckForStandbyTrigger(void)
1158711587
return false;
1158811588
}
1158911589

11590+
/*
11591+
* Remove the files signaling a standby promotion request.
11592+
*/
11593+
void
11594+
RemovePromoteSignalFiles(void)
11595+
{
11596+
unlink(PROMOTE_SIGNAL_FILE);
11597+
unlink(FALLBACK_PROMOTE_SIGNAL_FILE);
11598+
}
11599+
1159011600
/*
1159111601
* Check to see if a promote request has arrived. Should be
1159211602
* called by postmaster after receiving SIGUSR1.

‎src/backend/postmaster/postmaster.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,27 @@ PostmasterMain(int argc, char *argv[])
11751175
*/
11761176
RemovePgTempFiles();
11771177

1178+
/*
1179+
* Forcibly remove the files signaling a standby promotion
1180+
* request. Otherwise, the existence of those files triggers
1181+
* a promotion too early, whether a user wants that or not.
1182+
*
1183+
* This removal of files is usually unnecessary because they
1184+
* can exist only during a few moments during a standby
1185+
* promotion. However there is a race condition: if pg_ctl promote
1186+
* is executed and creates the files during a promotion,
1187+
* the files can stay around even after the server is brought up
1188+
* to new master. Then, if new standby starts by using the backup
1189+
* taken from that master, the files can exist at the server
1190+
* startup and should be removed in order to avoid an unexpected
1191+
* promotion.
1192+
*
1193+
* Note that promotion signal files need to be removed before
1194+
* the startup process is invoked. Because, after that, they can
1195+
* be used by postmaster's SIGUSR1 signal handler.
1196+
*/
1197+
RemovePromoteSignalFiles();
1198+
11781199
/*
11791200
* If enabled, start up syslogger collection subprocess
11801201
*/

‎src/include/access/xlog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ extern XLogRecPtr GetRedoRecPtr(void);
261261
externXLogRecPtrGetInsertRecPtr(void);
262262
externXLogRecPtrGetFlushRecPtr(void);
263263
externvoidGetNextXidAndEpoch(TransactionId*xid,uint32*epoch);
264+
externvoidRemovePromoteSignalFiles(void);
264265

265266
externboolCheckPromoteSignal(void);
266267
externvoidWakeupRecovery(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp