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

Commit2244c06

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 parented47666 commit2244c06

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
@@ -11336,6 +11336,16 @@ CheckForStandbyTrigger(void)
1133611336
return false;
1133711337
}
1133811338

11339+
/*
11340+
* Remove the files signaling a standby promotion request.
11341+
*/
11342+
void
11343+
RemovePromoteSignalFiles(void)
11344+
{
11345+
unlink(PROMOTE_SIGNAL_FILE);
11346+
unlink(FALLBACK_PROMOTE_SIGNAL_FILE);
11347+
}
11348+
1133911349
/*
1134011350
* Check to see if a promote request has arrived. Should be
1134111351
* 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
@@ -1170,6 +1170,27 @@ PostmasterMain(int argc, char *argv[])
11701170
*/
11711171
RemovePgTempFiles();
11721172

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

‎src/include/access/xlog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ extern XLogRecPtr GetRedoRecPtr(void);
336336
externXLogRecPtrGetInsertRecPtr(void);
337337
externXLogRecPtrGetFlushRecPtr(void);
338338
externvoidGetNextXidAndEpoch(TransactionId*xid,uint32*epoch);
339+
externvoidRemovePromoteSignalFiles(void);
339340

340341
externboolCheckPromoteSignal(void);
341342
externvoidWakeupRecovery(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp