@@ -993,66 +993,6 @@ PostmasterMain(int argc, char *argv[])
993
993
*/
994
994
InitializeMaxBackends ();
995
995
996
- /*
997
- * Initialize pipe (or process handle on Windows) that allows children to
998
- * wake up from sleep on postmaster death.
999
- */
1000
- InitPostmasterDeathWatchHandle ();
1001
-
1002
- /*
1003
- * Forcibly remove the files signaling a standby promotion request.
1004
- * Otherwise, the existence of those files triggers a promotion too early,
1005
- * whether a user wants that or not.
1006
- *
1007
- * This removal of files is usually unnecessary because they can exist
1008
- * only during a few moments during a standby promotion. However there is
1009
- * a race condition: if pg_ctl promote is executed and creates the files
1010
- * during a promotion, the files can stay around even after the server is
1011
- * brought up to new master. Then, if new standby starts by using the
1012
- * backup taken from that master, the files can exist at the server
1013
- * startup and should be removed in order to avoid an unexpected
1014
- * promotion.
1015
- *
1016
- * Note that promotion signal files need to be removed before the startup
1017
- * process is invoked. Because, after that, they can be used by
1018
- * postmaster's SIGUSR1 signal handler.
1019
- */
1020
- RemovePromoteSignalFiles ();
1021
-
1022
- /* Do the same for logrotate signal file */
1023
- RemoveLogrotateSignalFiles ();
1024
-
1025
- /* Remove any outdated file holding the current log filenames. */
1026
- if (unlink (LOG_METAINFO_DATAFILE ) < 0 && errno != ENOENT )
1027
- ereport (LOG ,
1028
- (errcode_for_file_access (),
1029
- errmsg ("could not remove file \"%s\": %m" ,
1030
- LOG_METAINFO_DATAFILE )));
1031
-
1032
- /*
1033
- * If enabled, start up syslogger collection subprocess
1034
- */
1035
- SysLoggerPID = SysLogger_Start ();
1036
-
1037
- /*
1038
- * Reset whereToSendOutput from DestDebug (its starting state) to
1039
- * DestNone. This stops ereport from sending log messages to stderr unless
1040
- * Log_destination permits. We don't do this until the postmaster is
1041
- * fully launched, since startup failures may as well be reported to
1042
- * stderr.
1043
- *
1044
- * If we are in fact disabling logging to stderr, first emit a log message
1045
- * saying so, to provide a breadcrumb trail for users who may not remember
1046
- * that their logging is configured to go somewhere else.
1047
- */
1048
- if (!(Log_destination & LOG_DESTINATION_STDERR ))
1049
- ereport (LOG ,
1050
- (errmsg ("ending log output to stderr" ),
1051
- errhint ("Future log output will go to log destination \"%s\"." ,
1052
- Log_destination_string )));
1053
-
1054
- whereToSendOutput = DestNone ;
1055
-
1056
996
/* Report server startup in log */
1057
997
ereport (LOG ,
1058
998
(errmsg ("starting %s" , PG_VERSION_STR )));
@@ -1248,6 +1188,12 @@ PostmasterMain(int argc, char *argv[])
1248
1188
*/
1249
1189
set_stack_base ();
1250
1190
1191
+ /*
1192
+ * Initialize pipe (or process handle on Windows) that allows children to
1193
+ * wake up from sleep on postmaster death.
1194
+ */
1195
+ InitPostmasterDeathWatchHandle ();
1196
+
1251
1197
#ifdef WIN32
1252
1198
1253
1199
/*
@@ -1301,6 +1247,60 @@ PostmasterMain(int argc, char *argv[])
1301
1247
*/
1302
1248
RemovePgTempFiles ();
1303
1249
1250
+ /*
1251
+ * Forcibly remove the files signaling a standby promotion request.
1252
+ * Otherwise, the existence of those files triggers a promotion too early,
1253
+ * whether a user wants that or not.
1254
+ *
1255
+ * This removal of files is usually unnecessary because they can exist
1256
+ * only during a few moments during a standby promotion. However there is
1257
+ * a race condition: if pg_ctl promote is executed and creates the files
1258
+ * during a promotion, the files can stay around even after the server is
1259
+ * brought up to new master. Then, if new standby starts by using the
1260
+ * backup taken from that master, the files can exist at the server
1261
+ * startup and should be removed in order to avoid an unexpected
1262
+ * promotion.
1263
+ *
1264
+ * Note that promotion signal files need to be removed before the startup
1265
+ * process is invoked. Because, after that, they can be used by
1266
+ * postmaster's SIGUSR1 signal handler.
1267
+ */
1268
+ RemovePromoteSignalFiles ();
1269
+
1270
+ /* Do the same for logrotate signal file */
1271
+ RemoveLogrotateSignalFiles ();
1272
+
1273
+ /* Remove any outdated file holding the current log filenames. */
1274
+ if (unlink (LOG_METAINFO_DATAFILE ) < 0 && errno != ENOENT )
1275
+ ereport (LOG ,
1276
+ (errcode_for_file_access (),
1277
+ errmsg ("could not remove file \"%s\": %m" ,
1278
+ LOG_METAINFO_DATAFILE )));
1279
+
1280
+ /*
1281
+ * If enabled, start up syslogger collection subprocess
1282
+ */
1283
+ SysLoggerPID = SysLogger_Start ();
1284
+
1285
+ /*
1286
+ * Reset whereToSendOutput from DestDebug (its starting state) to
1287
+ * DestNone. This stops ereport from sending log messages to stderr unless
1288
+ * Log_destination permits. We don't do this until the postmaster is
1289
+ * fully launched, since startup failures may as well be reported to
1290
+ * stderr.
1291
+ *
1292
+ * If we are in fact disabling logging to stderr, first emit a log message
1293
+ * saying so, to provide a breadcrumb trail for users who may not remember
1294
+ * that their logging is configured to go somewhere else.
1295
+ */
1296
+ if (!(Log_destination & LOG_DESTINATION_STDERR ))
1297
+ ereport (LOG ,
1298
+ (errmsg ("ending log output to stderr" ),
1299
+ errhint ("Future log output will go to log destination \"%s\"." ,
1300
+ Log_destination_string )));
1301
+
1302
+ whereToSendOutput = DestNone ;
1303
+
1304
1304
/*
1305
1305
* Initialize stats collection subsystem (this does NOT start the
1306
1306
* collector process!)
0 commit comments