*** a/src/backend/access/transam/xlog.c --- b/src/backend/access/transam/xlog.c *************** *** 67,73 **** extern uint32 bootstrap_data_checksum_version; #define RECOVERY_COMMAND_FILE "recovery.conf" #define RECOVERY_COMMAND_DONE "recovery.done" #define PROMOTE_SIGNAL_FILE "promote" - #define FAST_PROMOTE_SIGNAL_FILE "fast_promote" /* User-settable parameters */ --- 67,72 ---- *************** *** 227,235 **** static char *TriggerFile = NULL; /* are we currently in standby mode? */ bool StandbyMode = false; - /* whether request for fast promotion has been made yet */ - static bool fast_promote = false; - /* if recoveryStopsHere returns true, it saves actual stop xid/time/name here */ static TransactionId recoveryStopXid; static TimestampTz recoveryStopTime; --- 226,231 ---- *************** *** 6007,6013 **** StartupXLOG(void) DBState dbstate_at_startup; XLogReaderState *xlogreader; XLogPageReadPrivate private; ! bool fast_promoted = false; /* * Read control file and check XLOG status looks valid. --- 6003,6009 ---- DBState dbstate_at_startup; XLogReaderState *xlogreader; XLogPageReadPrivate private; ! bool end_of_recovery_ckpt = true; /* * Read control file and check XLOG status looks valid. *************** *** 7102,7115 **** StartupXLOG(void) * the rule that TLI only changes in shutdown checkpoints, which * allows some extra error checking in xlog_redo. * ! * In fast promotion, only create a lightweight end-of-recovery record * instead of a full checkpoint. A checkpoint is requested later, * after we're fully out of recovery mode and already accepting * queries. */ if (bgwriterLaunched) { ! if (fast_promote) { checkPointLoc = ControlFile->prevCheckPoint; --- 7098,7111 ---- * the rule that TLI only changes in shutdown checkpoints, which * allows some extra error checking in xlog_redo. * ! * In promotion, only create a lightweight end-of-recovery record * instead of a full checkpoint. A checkpoint is requested later, * after we're fully out of recovery mode and already accepting * queries. */ if (bgwriterLaunched) { ! if (CheckForStandbyTrigger()) { checkPointLoc = ControlFile->prevCheckPoint; *************** *** 7121,7127 **** StartupXLOG(void) record = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, false); if (record != NULL) { ! fast_promoted = true; /* * Insert a special WAL record to mark the end of --- 7117,7123 ---- record = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, false); if (record != NULL) { ! end_of_recovery_ckpt = false; /* * Insert a special WAL record to mark the end of *************** *** 7138,7144 **** StartupXLOG(void) } } ! if (!fast_promoted) RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE | CHECKPOINT_WAIT); --- 7134,7140 ---- } } ! if (end_of_recovery_ckpt) RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE | CHECKPOINT_WAIT); *************** *** 7251,7262 **** StartupXLOG(void) WalSndWakeup(); /* ! * If this was a fast promotion, request an (online) checkpoint now. This ! * isn't required for consistency, but the last restartpoint might be far ! * back, and in case of a crash, recovering from it might take a longer ! * than is appropriate now that we're not in standby mode anymore. */ ! if (fast_promoted) RequestCheckpoint(CHECKPOINT_FORCE); } --- 7247,7259 ---- WalSndWakeup(); /* ! * If an end-of-recovery checkpoint was not created, request an ! * (online) checkpoint now. This isn't required for consistency, ! * but the last restartpoint might be far back, and in case of a crash, ! * recovering from it might take a longer than is appropriate now ! * that we're not in standby mode anymore. */ ! if (!end_of_recovery_ckpt) RequestCheckpoint(CHECKPOINT_FORCE); } *************** *** 11080,11105 **** CheckForStandbyTrigger(void) if (IsPromoteTriggered()) { - /* - * In 9.1 and 9.2 the postmaster unlinked the promote file inside the - * signal handler. We now leave the file in place and let the Startup - * process do the unlink. This allows Startup to know whether we're - * doing fast or normal promotion. Fast promotion takes precedence. - */ - if (stat(FAST_PROMOTE_SIGNAL_FILE, &stat_buf) == 0) - { - unlink(FAST_PROMOTE_SIGNAL_FILE); - unlink(PROMOTE_SIGNAL_FILE); - fast_promote = true; - } - else if (stat(PROMOTE_SIGNAL_FILE, &stat_buf) == 0) - { - unlink(PROMOTE_SIGNAL_FILE); - fast_promote = false; - } - ereport(LOG, (errmsg("received promote request"))); ! ResetPromoteTriggered(); triggered = true; return true; --- 11077,11084 ---- if (IsPromoteTriggered()) { ereport(LOG, (errmsg("received promote request"))); ! unlink(PROMOTE_SIGNAL_FILE); ResetPromoteTriggered(); triggered = true; return true; *************** *** 11114,11120 **** CheckForStandbyTrigger(void) (errmsg("trigger file found: %s", TriggerFile))); unlink(TriggerFile); triggered = true; - fast_promote = true; return true; } return false; --- 11093,11098 ---- *************** *** 11129,11136 **** CheckPromoteSignal(void) { struct stat stat_buf; ! if (stat(PROMOTE_SIGNAL_FILE, &stat_buf) == 0 || ! stat(FAST_PROMOTE_SIGNAL_FILE, &stat_buf) == 0) return true; return false; --- 11107,11120 ---- { struct stat stat_buf; ! /* ! * In 9.1 and 9.2 the postmaster unlinked the promote file inside the ! * signal handler. We now leave the file in place and let the Startup ! * process do the unlink. This is the infrastructure for supporting ! * various promotion modes in the future. This allows Startup to know ! * the mode from the promote signal file that the postmaster left. ! */ ! if (stat(PROMOTE_SIGNAL_FILE, &stat_buf) == 0) return true; return false; *** a/src/bin/pg_ctl/pg_ctl.c --- b/src/bin/pg_ctl/pg_ctl.c *************** *** 1098,1111 **** do_promote(void) exit(1); } - /* - * For 9.3 onwards, use fast promotion as the default option. Promotion - * with a full checkpoint is still possible by writing a file called - * "promote", e.g. snprintf(promote_file, MAXPGPATH, "%s/promote", - * pg_data); - */ - snprintf(promote_file, MAXPGPATH, "%s/fast_promote", pg_data); - if ((prmfile = fopen(promote_file, "w")) == NULL) { write_stderr(_("%s: could not create promote signal file \"%s\": %s\n"), --- 1098,1103 ---- *************** *** 2239,2244 **** main(int argc, char **argv) --- 2231,2237 ---- snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pg_data); snprintf(backup_file, MAXPGPATH, "%s/backup_label", pg_data); snprintf(recovery_file, MAXPGPATH, "%s/recovery.conf", pg_data); + snprintf(promote_file, MAXPGPATH, "%s/promote", pg_data); } switch (ctl_command)