62 #include "utils/fmgrprotos.h"
69 #define RECOVERY_COMMAND_FILE "recovery.conf"
70 #define RECOVERY_COMMAND_DONE "recovery.done"
417 int emode,
bool fetching_ckpt,
421 int reqLen,
XLogRecPtr targetRecPtr,
char *readBuf);
514 bool *haveBackupLabel_ptr,
bool *haveTblspcMap_ptr)
521 bool haveTblspcMap =
false;
522 bool haveBackupLabel =
false;
524 bool backupFromStandby =
false;
559 .segment_open = NULL,
564 (
errcode(ERRCODE_OUT_OF_MEMORY),
566 errdetail(
"Failed while allocating a WAL reading processor.")));
618 (
errmsg(
"starting backup recovery with redo LSN %X/%X, checkpoint LSN %X/%X, on timeline ID %u",
650 (
errmsg(
"could not find redo location %X/%X referenced by checkpoint record at %X/%X",
652 errhint(
"If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n"
653 "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n"
654 "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup.",
661 (
errmsg(
"could not locate required checkpoint record at %X/%X",
663 errhint(
"If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n"
664 "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n"
665 "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup.",
675 foreach(lc, tablespaces)
691 errmsg(
"could not create symbolic link \"%s\": %m",
699 haveTblspcMap =
true;
703 haveBackupLabel =
true;
724 (
errmsg(
"ignoring file \"%s\" because no file \"%s\" exists",
726 errdetail(
"File \"%s\" was renamed to \"%s\".",
730 (
errmsg(
"ignoring file \"%s\" because no file \"%s\" exists",
732 errdetail(
"Could not rename file \"%s\" to \"%s\": %m.",
771 (
errmsg(
"restarting backup recovery with redo LSN %X/%X",
796 (
errmsg(
"could not locate a valid checkpoint record at %X/%X",
807 (
errmsg(
"entering standby mode")));
810 (
errmsg(
"starting point-in-time recovery to XID %u",
814 (
errmsg(
"starting point-in-time recovery to %s",
818 (
errmsg(
"starting point-in-time recovery to \"%s\"",
822 (
errmsg(
"starting point-in-time recovery to WAL location (LSN) \"%X/%X\"",
826 (
errmsg(
"starting point-in-time recovery to earliest consistent point")));
829 (
errmsg(
"starting archive recovery")));
850 (
errmsg(
"requested timeline %u is not a child of this server's history",
852 errdetail(
"Latest checkpoint is at %X/%X on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %X/%X.",
866 (
errmsg(
"requested timeline %u does not contain minimum recovery point %X/%X on timeline %u",
874 wasShutdown ?
"true" :
"false")));
894 (
errmsg(
"invalid next transaction ID")));
899 (
errmsg(
"invalid redo in checkpoint record")));
910 (
errmsg(
"invalid redo record in shutdown checkpoint")));
939 (
errmsg(
"database system was not properly shut down; "
940 "automatic recovery in progress")));
943 (
errmsg(
"crash recovery starts in timeline %u "
944 "and has target timeline %u",
981 if (backupFromStandby)
986 (
errmsg(
"backup_label contains data inconsistent with control file"),
987 errhint(
"This means that the backup is corrupted and you will "
988 "have to use another backup for recovery.")));
1015 *wasShutdown_ptr = wasShutdown;
1016 *haveBackupLabel_ptr = haveBackupLabel;
1017 *haveTblspcMap_ptr = haveTblspcMap;
1030 struct stat stat_buf;
1041 errmsg(
"using recovery command file \"%s\" is not supported",
1105 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1106 errmsg(
"standby mode is not supported by single-user servers")));
1123 (
errmsg(
"specified neither \"primary_conninfo\" nor \"restore_command\""),
1124 errhint(
"The database server will regularly poll the pg_wal subdirectory to check for files placed there.")));
1131 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1132 errmsg(
"must specify \"restore_command\" when standby mode is not enabled")));
1169 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1170 errmsg(
"recovery target timeline %u does not exist",
1217 char backuptype[20];
1218 char backupfrom[20];
1220 char backuptime[128];
1226 *backupLabelTLI = 0;
1228 *backupFromStandby =
false;
1236 if (errno != ENOENT)
1239 errmsg(
"could not read file \"%s\": %m",
1249 if (fscanf(lfp,
"START WAL LOCATION: %X/%X (file %08X%16s)%c",
1250 &hi, &lo, &tli_from_walseg, startxlogfilename, &ch) != 5 || ch !=
'\n')
1252 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1256 if (fscanf(lfp,
"CHECKPOINT LOCATION: %X/%X%c",
1257 &hi, &lo, &ch) != 3 || ch !=
'\n')
1259 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1261 *checkPointLoc = ((uint64) hi) << 32 | lo;
1262 *backupLabelTLI = tli_from_walseg;
1274 if (fscanf(lfp,
"BACKUP METHOD: %19s\n", backuptype) == 1)
1276 if (strcmp(backuptype,
"streamed") == 0)
1285 if (fscanf(lfp,
"BACKUP FROM: %19s\n", backupfrom) == 1)
1287 if (strcmp(backupfrom,
"standby") == 0)
1288 *backupFromStandby =
true;
1300 if (fscanf(lfp,
"START TIME: %127[^\n]\n", backuptime) == 1)
1305 if (fscanf(lfp,
"LABEL: %1023[^\n]\n", backuplabel) == 1)
1314 if (fscanf(lfp,
"START TIMELINE: %u\n", &tli_from_file) == 1)
1316 if (tli_from_walseg != tli_from_file)
1318 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1320 errdetail(
"Timeline ID parsed is %u, but expected %u.",
1321 tli_from_file, tli_from_walseg)));
1328 if (fscanf(lfp,
"INCREMENTAL FROM LSN: %X/%X\n", &hi, &lo) > 0)
1330 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1331 errmsg(
"this is an incremental backup, not a data directory"),
1332 errhint(
"Use pg_combinebackup to reconstruct a valid data directory.")));
1337 errmsg(
"could not read file \"%s\": %m",
1371 if (errno != ENOENT)
1374 errmsg(
"could not read file \"%s\": %m",
1385 was_backslash =
false;
1386 while ((ch = fgetc(lfp)) != EOF)
1388 if (!was_backslash && (ch ==
'\n' || ch ==
'\r'))
1402 while (
str[n] &&
str[n] !=
' ')
1404 if (n < 1 || n >=
i - 1)
1406 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1412 ti->
oid = strtoul(
str, &endp, 10);
1413 if (*endp !=
'\0' || errno == EINVAL || errno == ERANGE)
1415 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1418 *tablespaces =
lappend(*tablespaces, ti);
1423 else if (!was_backslash && ch ==
'\\')
1424 was_backslash =
true;
1427 if (
i <
sizeof(
str) - 1)
1429 was_backslash =
false;
1433 if (
i != 0 || was_backslash)
1435 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1441 errmsg(
"could not read file \"%s\": %m",
1562 if (endOfLog % XLOG_BLCKSZ != 0)
1568 pageBeginPtr = endOfLog - (endOfLog % XLOG_BLCKSZ);
1572 len = endOfLog % XLOG_BLCKSZ;
1632 unlink(recoveryPath);
1636 unlink(recoveryPath);
1656 bool reachedRecoveryTarget =
false;
1715 if (record->
xl_rmid != RM_XLOG_ID ||
1718 (
errmsg(
"unexpected record type found at redo point %X/%X",
1741 (
errmsg(
"redo starts at %X/%X",
1799 reachedRecoveryTarget =
true;
1828 reachedRecoveryTarget =
true;
1844 }
while (record != NULL);
1850 if (reachedRecoveryTarget)
1854 (
errmsg(
"requested recovery stop point is before consistent recovery point")));
1886 (
errmsg(
"redo done at %X/%X system usage: %s",
1892 (
errmsg(
"last completed transaction was at log time %s",
1901 (
errmsg(
"redo is not required")));
1910 !reachedRecoveryTarget)
1912 (
errcode(ERRCODE_CONFIG_FILE_ERROR),
1913 errmsg(
"recovery ended before configured recovery target was reached")));
1923 bool switchedTLI =
false;
1944 if (record->
xl_rmid == RM_XLOG_ID)
1967 if (newReplayTLI != *replayTLI)
1971 newReplayTLI, prevReplayTLI, *replayTLI);
1974 *replayTLI = newReplayTLI;
1999 if (record->
xl_rmid == RM_XLOG_ID)
2098 elog(
FATAL,
"mismatching overwritten LSN %X/%X -> %X/%X",
2107 (
errmsg(
"successfully skipped missing contrecord at %X/%X, overwritten at %s",
2130 elog(
DEBUG1,
"end of backup record reached");
2135 elog(
DEBUG1,
"saw end-of-backup record for backup starting at %X/%X, waiting for %X/%X",
2166 if (strspn(de->
d_name,
"0123456789") != strlen(de->
d_name))
2174 errmsg(
"unexpected directory entry \"%s\" found in %s",
2176 errdetail(
"All directory entries in %s/ should be symbolic links.",
2178 errhint(
"Remove those directories, or set \"allow_in_place_tablespaces\" to ON transiently to let recovery complete.")));
2230 (
errmsg(
"completed backup recovery with redo LSN %X/%X and end LSN %X/%X",
2260 (
errmsg(
"consistent recovery state reached at %X/%X",
2361 &rlocator, &forknum, &blk, NULL))
2394 if (prevTLI != replayTLI)
2396 (
errmsg(
"unexpected previous timeline ID %u (current timeline ID %u) in checkpoint record",
2397 prevTLI, replayTLI)));
2405 (
errmsg(
"unexpected timeline ID %u (after %u) in checkpoint record",
2406 newTLI, replayTLI)));
2421 (
errmsg(
"unexpected timeline ID %u in checkpoint record, before reaching minimum recovery point %X/%X on timeline %u",
2494 &rlocator, &forknum, &blkno, NULL))
2553 (
errcode(ERRCODE_INTERNAL_ERROR),
2570 "inconsistent page found, rel %u/%u/%u, forknum %u, blkno %u",
2588 bool stopsHere =
false;
2605 (
errmsg(
"recovery stopping after reaching consistency")));
2626 (
errmsg(
"recovery stopping before WAL location (LSN) \"%X/%X\"",
2716 (
errmsg(
"recovery stopping before commit of transaction %u, time %s",
2723 (
errmsg(
"recovery stopping before abort of transaction %u, time %s",
2776 (
errmsg(
"recovery stopping at restore point \"%s\", time %s",
2794 (
errmsg(
"recovery stopping after WAL location (LSN) \"%X/%X\"",
2799 if (rmid != RM_XACT_ID)
2861 (
errmsg(
"recovery stopping after commit of transaction %u, time %s",
2869 (
errmsg(
"recovery stopping after abort of transaction %u, time %s",
2881 (
errmsg(
"recovery stopping after reaching consistency")));
2905 "%s transaction %u",
2920 "at restore point \"%s\"",
2923 snprintf(reason,
sizeof(reason),
"reached consistency");
2925 snprintf(reason,
sizeof(reason),
"no recovery target specified");
2950 (
errmsg(
"pausing at the end of recovery"),
2951 errhint(
"Execute pg_wal_replay_resume() to promote.")));
2954 (
errmsg(
"recovery has paused"),
2955 errhint(
"Execute pg_wal_replay_resume() to continue.")));
2976 WAIT_EVENT_RECOVERY_PAUSE);
3069 elog(
DEBUG2,
"recovery apply delay %ld milliseconds", msecs);
3074 WAIT_EVENT_RECOVERY_APPLY_DELAY);
3152 private->fetching_ckpt = fetching_ckpt;
3153 private->emode = emode;
3155 private->replayTLI = replayTLI;
3218 (
errmsg(
"unexpected timeline ID %u in WAL segment %s, LSN %X/%X, offset %u",
3252 (
errmsg_internal(
"reached end of WAL in pg_wal, entering archive recovery")));
3316 int emode = private->emode;
3365 private->randAccess,
3366 private->fetching_ckpt,
3400 if (((targetPagePtr) / XLOG_BLCKSZ) != (
flushedUpto / XLOG_BLCKSZ))
3414 if (r != XLOG_BLCKSZ)
3417 int save_errno = errno;
3426 errmsg(
"could not read from WAL segment %s, LSN %X/%X, offset %u: %m",
3433 errmsg(
"could not read from WAL segment %s, LSN %X/%X, offset %u: read %d of %zu",
3436 goto next_record_is_invalid;
3491 goto next_record_is_invalid;
3496 next_record_is_invalid:
3561 bool streaming_reply_sent =
false;
3601 bool startWalReceiver =
false;
3648 startWalReceiver =
true;
3711 elog(
LOG,
"waiting for WAL to become available at %X/%X",
3721 WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL);
3728 last_fail_time =
now;
3748 elog(
DEBUG2,
"switched WAL source from %s to %s after %s",
3822 startWalReceiver =
true;
3835 if (startWalReceiver &&
3857 elog(
ERROR,
"according to history file, WAL location %X/%X belongs to timeline %u, but previous recovered WAL file came from timeline %u",
3900 if (latestChunkStart <= RecPtr)
3976 if (!streaming_reply_sent)
3979 streaming_reply_sent =
true;
3995 WAIT_EVENT_RECOVERY_WAL_STREAM);
4048 if (RecPtr == lastComplaint)
4051 lastComplaint = RecPtr;
4072 (
errmsg(
"invalid checkpoint location")));
4082 (
errmsg(
"invalid checkpoint record")));
4085 if (record->
xl_rmid != RM_XLOG_ID)
4088 (
errmsg(
"invalid resource manager ID in checkpoint record")));
4096 (
errmsg(
"invalid xl_info in checkpoint record")));
4102 (
errmsg(
"invalid length of checkpoint record")));
4118 List *newExpectedTLEs;
4143 foreach(cell, newExpectedTLEs)
4156 (
errmsg(
"new timeline %u is not a child of database system timeline %u",
4167 if (currentTle->
end < replayLSN)
4170 (
errmsg(
"new timeline %u forked off current database system timeline %u before current recovery point %X/%X",
4189 (
errmsg(
"new target timeline is %u",
4217 snprintf(activitymsg,
sizeof(activitymsg),
"waiting for %s",
4259 snprintf(activitymsg,
sizeof(activitymsg),
"recovering %s",
4272 if (errno != ENOENT || !notfoundOk)
4275 errmsg(
"could not open file \"%s\": %m", path)));
4343 if (segno < beginseg)
4352 elog(
DEBUG1,
"got WAL segment from archive");
4376 errmsg(
"could not open file \"%s\": %m", path)));
4390 (
errmsg(
"WAL receiver process shutdown requested")));
4475 struct stat stat_buf;
4583 *replayEndTLI = tli;
4671 if (currValue < minValue)
4675 bool warned_for_promote =
false;
4678 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4679 errmsg(
"hot standby is not possible because of insufficient parameter settings"),
4680 errdetail(
"%s = %d is a lower setting than on the primary server, where its value was %d.",
4688 (
errmsg(
"recovery has paused"),
4689 errdetail(
"If recovery is unpaused, the server will shut down."),
4690 errhint(
"You can then restart the server after making the necessary configuration changes.")));
4698 if (!warned_for_promote)
4700 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4701 errmsg(
"promotion is not possible because of insufficient parameter settings"),
4707 errdetail(
"%s = %d is a lower setting than on the primary server, where its value was %d.",
4711 errhint(
"Restart the server after making the necessary configuration changes.")));
4712 warned_for_promote =
true;
4728 WAIT_EVENT_RECOVERY_PAUSE);
4734 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4735 errmsg(
"recovery aborted because of insufficient parameter settings"),
4737 errdetail(
"%s = %d is a lower setting than on the primary server, where its value was %d.",
4741 errhint(
"You can restart the server after making the necessary configuration changes.")));
4779 error_multiple_recovery_targets(
void)
4782 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
4783 errmsg(
"multiple recovery targets specified"),
4784 errdetail(
"At most one of \"recovery_target\", \"recovery_target_lsn\", \"recovery_target_name\", \"recovery_target_time\", \"recovery_target_xid\" may be set.")));
4793 if (strcmp(*
newval,
"immediate") != 0 && strcmp(*
newval,
"") != 0)
4809 error_multiple_recovery_targets();
4823 if (strcmp(*
newval,
"") != 0)
4827 bool have_error =
false;
4835 *extra = (
void *) myextra;
4848 error_multiple_recovery_targets();
4883 error_multiple_recovery_targets();
4906 if (strcmp(*
newval,
"") != 0)
4909 if (strcmp(*
newval,
"now") == 0 ||
4910 strcmp(*
newval,
"today") == 0 ||
4911 strcmp(*
newval,
"tomorrow") == 0 ||
4912 strcmp(*
newval,
"yesterday") == 0)
4939 &dtype,
tm, &fsec, &tz, &dtextra);
4963 error_multiple_recovery_targets();
4980 if (strcmp(*
newval,
"current") == 0)
4982 else if (strcmp(*
newval,
"latest") == 0)
4989 strtoul(*
newval, NULL, 0);
4990 if (errno == EINVAL || errno == ERANGE)
4999 *extra = (
void *) myextra;
5023 if (strcmp(*
newval,
"") != 0)
5030 if (errno == EINVAL || errno == ERANGE)
5035 *extra = (
void *) myextra;
5048 error_multiple_recovery_targets();
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
TimeLineID findNewestTimeLine(TimeLineID startTLI)
TimeLineID tliOfPointInHistory(XLogRecPtr ptr, List *history)
XLogRecPtr tliSwitchPoint(TimeLineID tli, List *history, TimeLineID *nextTLI)
bool existsTimeLineHistory(TimeLineID probeTLI)
void restoreTimeLineHistoryFiles(TimeLineID begin, TimeLineID end)
List * readTimeLineHistory(TimeLineID targetTLI)
bool tliInHistory(TimeLineID tli, List *expectedTLEs)
void remove_tablespace_symlink(const char *linkloc)
bool allow_in_place_tablespaces
void HandleStartupProcInterrupts(void)
void disable_startup_progress_timeout(void)
bool IsPromoteSignaled(void)
void begin_startup_progress_phase(void)
void ResetPromoteSignaled(void)
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
Datum timestamptz_in(PG_FUNCTION_ARGS)
TimestampTz GetCurrentTimestamp(void)
Datum now(PG_FUNCTION_ARGS)
const char * timestamptz_to_str(TimestampTz t)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
static Page BufferGetPage(Buffer buffer)
#define BUFFER_LOCK_EXCLUSIVE
static bool BufferIsValid(Buffer bufnum)
static XLogRecPtr PageGetLSN(const char *page)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define strtou64(str, endptr, base)
void RequestCheckpoint(int flags)
bool ConditionVariableCancelSleep(void)
bool ConditionVariableTimedSleep(ConditionVariable *cv, long timeout, uint32 wait_event_info)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
int errmsg_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
struct dirent * ReadDir(DIR *dir, const char *dirname)
FILE * AllocateFile(const char *name, const char *mode)
int BasicOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
int durable_rename(const char *oldfile, const char *newfile, int elevel)
int BasicOpenFile(const char *fileName, int fileFlags)
DIR * AllocateDir(const char *dirname)
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
bool IsPostmasterEnvironment
void * guc_malloc(int elevel, size_t size)
#define GUC_check_errdetail
void OwnLatch(Latch *latch)
void DisownLatch(Latch *latch)
void InitSharedLatch(Latch *latch)
void SetLatch(Latch *latch)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_EXIT_ON_PM_DEATH
List * lappend(List *list, void *datum)
void list_free_deep(List *list)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
#define AmStartupProcess()
#define IsBootstrapProcessingMode()
#define ERRCODE_DATA_CORRUPTED
#define XLOG_RESTORE_POINT
#define XLOG_CHECKPOINT_REDO
#define XLOG_OVERWRITE_CONTRECORD
@ DB_SHUTDOWNED_IN_RECOVERY
#define XLOG_CHECKPOINT_SHUTDOWN
#define XLOG_CHECKPOINT_ONLINE
#define XLOG_END_OF_RECOVERY
XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error)
static rewind_source * source
const char * pg_rusage_show(const PGRUsage *ru0)
void pg_rusage_init(PGRUsage *ru0)
void SendPostmasterSignal(PMSignalReason reason)
@ PMSIGNAL_RECOVERY_STARTED
@ PMSIGNAL_BEGIN_HOT_STANDBY
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int fd(const char *x, int i)
void RecordKnownAssignedTransactionIds(TransactionId xid)
void KnownAssignedTransactionIdsIdleMaintenance(void)
static void set_ps_display(const char *activity)
char * psprintf(const char *fmt,...)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
static pg_noinline void Size size
bool ReplicationSlotValidateName(const char *name, int elevel)
void ShutDownSlotSync(void)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
#define ereport_startup_progress(msg,...)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
MultiXactOffset nextMultiOffset
TransactionId newestCommitTsXid
TimeLineID PrevTimeLineID
TimeLineID ThisTimeLineID
FullTransactionId nextXid
TransactionId oldestCommitTsXid
XLogRecPtr backupStartPoint
CheckPoint checkPointCopy
XLogRecPtr backupEndPoint
XLogRecPtr minRecoveryPoint
TimeLineID minRecoveryPointTLI
bool standby_signal_file_found
XLogRecPtr lastPageBeginPtr
char * recoveryStopReason
XLogRecPtr missingContrecPtr
bool recovery_signal_file_found
struct ErrorContextCallback * previous
void(* callback)(void *arg)
void(* rm_mask)(char *pagedata, BlockNumber blkno)
void(* rm_redo)(XLogReaderState *record)
const char *(* rm_identify)(uint8 info)
void(* rm_desc)(StringInfo buf, XLogReaderState *record)
pg_atomic_uint64 minWaitedLSN
XLogRecPtr missingContrecPtr
XLogRecPtr overwrittenRecPtr
ConditionVariable recoveryNotPausedCV
XLogRecPtr lastReplayedEndRecPtr
bool SharedHotStandbyActive
TimeLineID lastReplayedTLI
bool SharedPromoteIsTriggered
TimestampTz currentChunkStartTime
XLogRecPtr replayEndRecPtr
Latch recoveryWakeupLatch
TimestampTz recoveryLastXTime
RecoveryPauseState recoveryPauseState
XLogRecPtr lastReplayedReadRecPtr
TimeLineID PrevTimeLineID
TimeLineID ThisTimeLineID
TimestampTz overwrite_time
XLogRecPtr overwritten_lsn
char rp_name[MAXFNAMELEN]
TransactionId twophase_xid
TransactionId twophase_xid
#define InvalidTransactionId
#define U64FromFullTransactionId(x)
#define XidFromFullTransactionId(x)
#define TransactionIdIsValid(xid)
#define TransactionIdIsNormal(xid)
#define TimestampTzPlusMilliseconds(tz, ms)
static TimestampTz DatumGetTimestampTz(Datum X)
void AdvanceNextFullTransactionIdPastXid(TransactionId xid)
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)
struct WaitLSNState * waitLSNState
void WaitLSNSetLatches(XLogRecPtr currentLSN)
void WalRcvForceReply(void)
#define AllowCascadeReplication()
XLogRecPtr GetWalRcvFlushRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)
bool WalRcvStreaming(void)
void RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo, const char *slotname, bool create_temp_slot)
void WalSndWakeup(bool physical, bool logical)
#define symlink(oldpath, newpath)
#define XLOG_XACT_COMMIT_PREPARED
#define XLOG_XACT_ABORT_PREPARED
void ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *parsed)
void ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
int wal_decode_buffer_size
XLogRecPtr GetRedoRecPtr(void)
void SetInstallXLogFileSegmentActive(void)
bool IsInstallXLogFileSegmentActive(void)
void SwitchIntoArchiveRecovery(XLogRecPtr EndRecPtr, TimeLineID replayTLI)
void RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
void ReachedEndOfBackup(XLogRecPtr EndRecPtr, TimeLineID tli)
int wal_retrieve_retry_interval
static ControlFileData * ControlFile
void XLogShutdownWalRcv(void)
bool XLogCheckpointNeeded(XLogSegNo new_segno)
#define TABLESPACE_MAP_OLD
#define STANDBY_SIGNAL_FILE
#define CHECKPOINT_CAUSE_XLOG
#define PROMOTE_SIGNAL_FILE
#define BACKUP_LABEL_FILE
#define RECOVERY_SIGNAL_FILE
static RmgrData GetRmgr(RmgrId rmid)
@ RECOVERY_TARGET_ACTION_PAUSE
@ RECOVERY_TARGET_ACTION_PROMOTE
@ RECOVERY_TARGET_ACTION_SHUTDOWN
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFilePath(char *path, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define XRecOffIsValid(xlrp)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
#define XLByteInSeg(xlrp, logSegNo, wal_segsz_bytes)
bool RestoreArchivedFile(char *path, const char *xlogfname, const char *recovername, off_t expectedSize, bool cleanupEnabled)
void KeepFileRestoredFromArchive(const char *path, const char *xlogfname)
#define LSN_FORMAT_ARGS(lsn)
#define XLogRecPtrIsInvalid(r)
#define InvalidXLogRecPtr
void XLogPrefetcherComputeStats(XLogPrefetcher *prefetcher)
XLogRecord * XLogPrefetcherReadRecord(XLogPrefetcher *prefetcher, char **errmsg)
void XLogPrefetchReconfigure(void)
XLogPrefetcher * XLogPrefetcherAllocate(XLogReaderState *reader)
void XLogPrefetcherBeginRead(XLogPrefetcher *prefetcher, XLogRecPtr recPtr)
void XLogPrefetcherFree(XLogPrefetcher *prefetcher)
XLogReaderState * XLogPrefetcherGetReader(XLogPrefetcher *prefetcher)
bool XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum, Buffer *prefetch_buffer)
void XLogReaderSetDecodeBuffer(XLogReaderState *state, void *buffer, size_t size)
void XLogReaderResetError(XLogReaderState *state)
bool XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, char *phdr)
void XLogReaderFree(XLogReaderState *state)
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, XLogReaderRoutine *routine, void *private_data)
bool RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
#define XLogRecGetDataLen(decoder)
#define XLogRecGetInfo(decoder)
#define XLogRecBlockImageApply(decoder, block_id)
#define XLogRecGetRmid(decoder)
#define XLogRecGetData(decoder)
#define XLogRecGetXid(decoder)
#define XLogRecMaxBlockId(decoder)
#define XLogRecHasBlockImage(decoder, block_id)
#define XLogRecGetPrev(decoder)
#define XLogRecHasAnyBlockRefs(decoder)
#define SizeOfXLogRecordDataHeaderShort
#define XLR_CHECK_CONSISTENCY
bool check_primary_slot_name(char **newval, void **extra, GucSource source)
static bool getRecordTimestamp(XLogReaderState *record, TimestampTz *recordXtime)
static XLogRecPtr recoveryStopLSN
static bool recoveryStopsBefore(XLogReaderState *record)
static TimestampTz recoveryStopTime
void assign_recovery_target_xid(const char *newval, void *extra)
static bool CheckForStandbyTrigger(void)
int recovery_min_apply_delay
bool check_recovery_target(char **newval, void **extra, GucSource source)
static bool backupEndRequired
bool HotStandbyActive(void)
static char * getRecoveryStopReason(void)
void ShutdownWalRecovery(void)
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
static void rm_redo_error_callback(void *arg)
static bool recoveryApplyDelay(XLogReaderState *record)
bool ArchiveRecoveryRequested
const char * recoveryTargetName
static void xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI)
static void pg_attribute_noreturn() error_multiple_recovery_targets(void)
bool check_recovery_target_timeline(char **newval, void **extra, GucSource source)
static XLogRecPtr minRecoveryPoint
static int XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *readBuf)
static XLogRecPtr backupEndPoint
const struct config_enum_entry recovery_target_action_options[]
static void validateRecoveryParameters(void)
static void checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI, TimeLineID replayTLI)
static XLogRecord * ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr, TimeLineID replayTLI)
void StartupRequestWalReceiverRestart(void)
static bool recoveryStopsAfter(XLogReaderState *record)
void RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue)
static TimeLineID curFileTLI
static char recoveryStopName[MAXFNAMELEN]
static void CheckRecoveryConsistency(void)
static bool pendingWalRcvRestart
void PerformWalRecovery(void)
static XLogSource XLogReceiptSource
bool CheckPromoteSignal(void)
struct XLogPageReadPrivate XLogPageReadPrivate
static bool recoveryStopAfter
static const char *const xlogSourceNames[]
static TimeLineID RedoStartTLI
char * recoveryRestoreCommand
static void verifyBackupPageConsistency(XLogReaderState *record)
static int XLogFileReadAnyTLI(XLogSegNo segno, XLogSource source)
void assign_recovery_target(const char *newval, void *extra)
void SetRecoveryPause(bool recoveryPause)
EndOfWalRecoveryInfo * FinishWalRecovery(void)
static bool lastSourceFailed
char * archiveCleanupCommand
XLogRecPtr GetCurrentReplayRecPtr(TimeLineID *replayEndTLI)
static TimeLineID receiveTLI
void WakeupRecovery(void)
void xlog_outdesc(StringInfo buf, XLogReaderState *record)
static bool LocalPromoteIsTriggered
bool PromoteIsTriggered(void)
TimestampTz GetCurrentChunkReplayStartTime(void)
static void ConfirmRecoveryPaused(void)
static void readRecoverySignalFile(void)
static XLogRecPtr missingContrecPtr
static XLogRecoveryCtlData * XLogRecoveryCtl
static bool standby_signal_file_found
char * recovery_target_time_string
static XLogPageReadResult WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, bool fetching_ckpt, XLogRecPtr tliRecPtr, TimeLineID replayTLI, XLogRecPtr replayLSN, bool nonblocking)
XLogRecPtr recoveryTargetLSN
RecoveryTargetType recoveryTarget
static bool read_tablespace_map(List **tablespaces)
static bool doRequestWalReceiverReply
static bool read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI, bool *backupEndRequired, bool *backupFromStandby)
static int XLogFileRead(XLogSegNo segno, TimeLineID tli, XLogSource source, bool notfoundOk)
static XLogSource currentSource
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream)
static List * expectedTLEs
static XLogSegNo readSegNo
void assign_recovery_target_name(const char *newval, void *extra)
static XLogRecPtr abortedRecPtr
static char * primary_image_masked
static TimeLineID minRecoveryPointTLI
static XLogRecord * ReadRecord(XLogPrefetcher *xlogprefetcher, int emode, bool fetching_ckpt, TimeLineID replayTLI)
void assign_recovery_target_time(const char *newval, void *extra)
static void SetCurrentChunkStartTime(TimestampTz xtime)
static XLogRecPtr CheckPointLoc
bool check_recovery_target_xid(char **newval, void **extra, GucSource source)
static bool LocalHotStandbyActive
struct XLogRecoveryCtlData XLogRecoveryCtlData
static bool HotStandbyActiveInReplay(void)
static TransactionId recoveryStopXid
bool check_recovery_target_time(char **newval, void **extra, GucSource source)
static XLogSource readSource
static void SetPromoteIsTriggered(void)
#define RECOVERY_COMMAND_FILE
TransactionId recoveryTargetXid
TimeLineID recoveryTargetTLIRequested
void InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, bool *haveBackupLabel_ptr, bool *haveTblspcMap_ptr)
static void xlog_block_info(StringInfo buf, XLogReaderState *record)
static TimestampTz XLogReceiptTime
static void ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *replayTLI)
Size XLogRecoveryShmemSize(void)
static char * replay_image_masked
bool wal_receiver_create_temp_slot
static void CheckTablespaceDirectory(void)
char * recoveryEndCommand
RecoveryPauseState GetRecoveryPauseState(void)
TimeLineID recoveryTargetTLI
static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr)
void assign_recovery_target_lsn(const char *newval, void *extra)
bool check_recovery_target_lsn(char **newval, void **extra, GucSource source)
static XLogRecPtr RedoStartLSN
static XLogRecPtr flushedUpto
void XLogRecoveryShmemInit(void)
static void recoveryPausesHere(bool endOfRecovery)
static void EnableStandbyMode(void)
#define RECOVERY_COMMAND_DONE
static bool recovery_signal_file_found
TimestampTz recoveryTargetTime
TimestampTz GetLatestXTime(void)
void XLogRequestWalReceiverReply(void)
static bool rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
static XLogPrefetcher * xlogprefetcher
static bool StandbyModeRequested
bool check_recovery_target_name(char **newval, void **extra, GucSource source)
bool recoveryTargetInclusive
static XLogReaderState * xlogreader
void RemovePromoteSignalFiles(void)
void assign_recovery_target_timeline(const char *newval, void *extra)
static XLogRecPtr backupStartPoint
static void SetLatestXTime(TimestampTz xtime)
static TimeLineID CheckPointTLI
@ RECOVERY_TARGET_IMMEDIATE
RecoveryTargetTimeLineGoal
@ RECOVERY_TARGET_TIMELINE_NUMERIC
@ RECOVERY_TARGET_TIMELINE_CONTROLFILE
@ RECOVERY_TARGET_TIMELINE_LATEST
@ RECOVERY_PAUSE_REQUESTED
void wal_segment_close(XLogReaderState *state)
Buffer XLogReadBufferExtended(RelFileLocator rlocator, ForkNumber forknum, BlockNumber blkno, ReadBufferMode mode, Buffer recent_buffer)
HotStandbyState standbyState
void XLogCheckInvalidPages(void)