PostgreSQL Source Code
git master
|
#include "access/xlogreader.h"
#include "catalog/pg_control.h"
#include "lib/stringinfo.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | EndOfWalRecoveryInfo |
Typedefs | |
typedef enum RecoveryPauseState | RecoveryPauseState |
typedef enum RecoveryPauseState RecoveryPauseState |
enum RecoveryPauseState |
Enumerator | |
---|---|
RECOVERY_NOT_PAUSED | |
RECOVERY_PAUSE_REQUESTED | |
RECOVERY_PAUSED |
Definition at line 44 of file xlogrecovery.h.
Enumerator | |
---|---|
RECOVERY_TARGET_TIMELINE_CONTROLFILE | |
RECOVERY_TARGET_TIMELINE_LATEST | |
RECOVERY_TARGET_TIMELINE_NUMERIC |
Definition at line 36 of file xlogrecovery.h.
enum RecoveryTargetType |
Enumerator | |
---|---|
RECOVERY_TARGET_UNSET | |
RECOVERY_TARGET_XID | |
RECOVERY_TARGET_TIME | |
RECOVERY_TARGET_NAME | |
RECOVERY_TARGET_LSN | |
RECOVERY_TARGET_IMMEDIATE |
Definition at line 23 of file xlogrecovery.h.
bool CheckPromoteSignal | ( | void | ) |
Definition at line 4462 of file xlogrecovery.c.
References PROMOTE_SIGNAL_FILE, and stat.
Referenced by CheckForStandbyTrigger(), and process_pm_pmsignal().
EndOfWalRecoveryInfo* FinishWalRecovery | ( | void | ) |
Definition at line 1458 of file xlogrecovery.c.
References abortedRecPtr, EndOfWalRecoveryInfo::abortedRecPtr, ArchiveRecoveryRequested, Assert, CheckPointLoc, CheckPointTLI, close, EndOfWalRecoveryInfo::endOfLog, EndOfWalRecoveryInfo::endOfLogTLI, XLogReaderState::EndRecPtr, getRecoveryStopReason(), InArchiveRecovery, InRecovery, EndOfWalRecoveryInfo::lastPage, EndOfWalRecoveryInfo::lastPageBeginPtr, EndOfWalRecoveryInfo::lastRec, EndOfWalRecoveryInfo::lastRecTLI, XLogRecoveryCtlData::lastReplayedReadRecPtr, XLogRecoveryCtlData::lastReplayedTLI, len, missingContrecPtr, EndOfWalRecoveryInfo::missingContrecPtr, palloc(), PANIC, XLogReaderState::readBuf, readFile, readOff, ReadRecord(), recovery_signal_file_found, EndOfWalRecoveryInfo::recovery_signal_file_found, EndOfWalRecoveryInfo::recoveryStopReason, XLogReaderState::seg, ShutDownSlotSync(), standby_signal_file_found, EndOfWalRecoveryInfo::standby_signal_file_found, StandbyMode, wal_segment_size, WalRcvStreaming(), WALOpenSegment::ws_tli, xlogprefetcher, XLogPrefetcherBeginRead(), xlogreader, XLogRecoveryCtl, XLogSegmentOffset, and XLogShutdownWalRcv().
Referenced by StartupXLOG().
TimestampTz GetCurrentChunkReplayStartTime | ( | void | ) |
Definition at line 4625 of file xlogrecovery.c.
References XLogRecoveryCtlData::currentChunkStartTime, XLogRecoveryCtlData::info_lck, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by GetReplicationApplyDelay().
XLogRecPtr GetCurrentReplayRecPtr | ( | TimeLineID * | replayEndTLI | ) |
Definition at line 4561 of file xlogrecovery.c.
References XLogRecoveryCtlData::info_lck, XLogRecoveryCtlData::replayEndRecPtr, XLogRecoveryCtlData::replayEndTLI, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by UpdateMinRecoveryPoint(), and xlog_redo().
TimestampTz GetLatestXTime | ( | void | ) |
Definition at line 4595 of file xlogrecovery.c.
References XLogRecoveryCtlData::info_lck, XLogRecoveryCtlData::recoveryLastXTime, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by CreateRestartPoint(), PerformWalRecovery(), and pg_last_xact_replay_timestamp().
RecoveryPauseState GetRecoveryPauseState | ( | void | ) |
Definition at line 3072 of file xlogrecovery.c.
References XLogRecoveryCtlData::info_lck, XLogRecoveryCtlData::recoveryPauseState, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by pg_get_wal_replay_pause_state(), pg_is_wal_replay_paused(), recoveryPausesHere(), and RecoveryRequiresIntParameter().
void GetXLogReceiptTime | ( | TimestampTz * | rtime, |
bool * | fromStream | ||
) |
Definition at line 4641 of file xlogrecovery.c.
References Assert, InRecovery, XLOG_FROM_STREAM, XLogReceiptSource, and XLogReceiptTime.
Referenced by GetStandbyLimitTime().
XLogRecPtr GetXLogReplayRecPtr | ( | TimeLineID * | replayTLI | ) |
Definition at line 4538 of file xlogrecovery.c.
References XLogRecoveryCtlData::info_lck, XLogRecoveryCtlData::lastReplayedEndRecPtr, XLogRecoveryCtlData::lastReplayedTLI, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by CheckpointerMain(), CreateRestartPoint(), GetCurrentLSN(), GetLatestLSN(), GetReplicationApplyDelay(), GetStandbyFlushRecPtr(), IsCheckpointOnSchedule(), logical_read_xlog_page(), pg_last_wal_replay_lsn(), pg_logical_slot_get_changes_guts(), pg_replication_slot_advance(), read_local_xlog_page_guts(), ReadReplicationSlot(), ReplicationSlotReserveWal(), WalReceiverMain(), WalSndWaitForWal(), and XLogWalRcvSendReply().
bool HotStandbyActive | ( | void | ) |
Definition at line 4501 of file xlogrecovery.c.
References XLogRecoveryCtlData::info_lck, LocalHotStandbyActive, XLogRecoveryCtlData::SharedHotStandbyActive, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by XLogWalRcvSendHSFeedback().
void InitWalRecovery | ( | ControlFileData * | ControlFile, |
bool * | wasShutdown_ptr, | ||
bool * | haveBackupLabel_ptr, | ||
bool * | haveTblspcMap_ptr | ||
) |
Definition at line 512 of file xlogrecovery.c.
References abortedRecPtr, ArchiveRecoveryRequested, Assert, BACKUP_LABEL_FILE, backupEndPoint, ControlFileData::backupEndPoint, backupEndRequired, ControlFileData::backupEndRequired, backupStartPoint, ControlFileData::backupStartPoint, ControlFileData::checkPoint, ControlFileData::checkPointCopy, CheckPointLoc, CheckPointTLI, ControlFile, DataDir, DB_IN_ARCHIVE_RECOVERY, DB_IN_CRASH_RECOVERY, DB_SHUTDOWNED, DB_SHUTDOWNED_IN_RECOVERY, DEBUG1, durable_rename(), EnableStandbyMode(), ereport, errcode(), errcode_for_file_access(), errdetail(), errhint(), errmsg(), errmsg_internal(), ERROR, expectedTLEs, FATAL, InArchiveRecovery, InRecovery, InvalidXLogRecPtr, lfirst, LOG, LSN_FORMAT_ARGS, minRecoveryPoint, ControlFileData::minRecoveryPoint, minRecoveryPointTLI, ControlFileData::minRecoveryPointTLI, missingContrecPtr, CheckPoint::newestCommitTsXid, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, NIL, tablespaceinfo::oid, CheckPoint::oldestCommitTsXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, OwnLatch(), palloc(), palloc0(), PANIC, tablespaceinfo::path, pfree(), PG_TBLSPC_DIR, primary_image_masked, psprintf(), read_backup_label(), read_tablespace_map(), ReadCheckpointRecord(), ReadRecord(), readRecoverySignalFile(), RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_LSN, RECOVERY_TARGET_NAME, RECOVERY_TARGET_TIME, RECOVERY_TARGET_XID, recoveryTarget, recoveryTargetLSN, recoveryTargetName, recoveryTargetTime, recoveryTargetTLI, recoveryTargetXid, XLogRecoveryCtlData::recoveryWakeupLatch, CheckPoint::redo, RedoStartLSN, RedoStartTLI, remove_tablespace_symlink(), replay_image_masked, StandbyModeRequested, stat, ControlFileData::state, symlink, XLogReaderState::system_identifier, ControlFileData::system_identifier, TABLESPACE_MAP, TABLESPACE_MAP_OLD, CheckPoint::ThisTimeLineID, timestamptz_to_str(), tliOfPointInHistory(), tliSwitchPoint(), TransactionIdIsNormal, U64FromFullTransactionId, UINT64_FORMAT, validateRecoveryParameters(), wal_decode_buffer_size, wal_segment_close(), wal_segment_size, XidFromFullTransactionId, XLogRecord::xl_info, XL_ROUTINE, XLOG_CHECKPOINT_SHUTDOWN, XLogPageRead(), xlogprefetcher, XLogPrefetcherAllocate(), XLogPrefetcherBeginRead(), xlogreader, XLogReaderAllocate(), XLogReaderSetDecodeBuffer(), XLogRecGetData, XLogRecoveryCtl, XLogRecPtrIsInvalid, and XLR_INFO_MASK.
Referenced by StartupXLOG().
void PerformWalRecovery | ( | void | ) |
Definition at line 1652 of file xlogrecovery.c.
References appendStringInfo(), appendStringInfoString(), ApplyWalRecord(), ArchiveRecoveryRequested, Assert, begin_startup_progress_phase(), buf, CheckPointLoc, CheckPointTLI, CheckRecoveryConsistency(), XLogRecoveryCtlData::currentChunkStartTime, elog, XLogReaderState::EndRecPtr, ereport, ereport_startup_progress, errcode(), errmsg(), FATAL, GetCurrentTimestamp(), GetLatestXTime(), HandleStartupProcInterrupts(), XLogRecoveryCtlData::info_lck, initStringInfo(), InRedo, InvalidXLogRecPtr, IsUnderPostmaster, XLogRecoveryCtlData::lastReplayedEndRecPtr, XLogRecoveryCtlData::lastReplayedReadRecPtr, XLogRecoveryCtlData::lastReplayedTLI, LOG, LSN_FORMAT_ARGS, PANIC, pfree(), pg_rusage_init(), pg_rusage_show(), PMSIGNAL_RECOVERY_STARTED, proc_exit(), reachedConsistency, ReadRecord(), XLogReaderState::ReadRecPtr, RECOVERY_NOT_PAUSED, RECOVERY_TARGET_ACTION_PAUSE, RECOVERY_TARGET_ACTION_PROMOTE, RECOVERY_TARGET_ACTION_SHUTDOWN, RECOVERY_TARGET_UNSET, recoveryApplyDelay(), XLogRecoveryCtlData::recoveryLastXTime, recoveryPausesHere(), XLogRecoveryCtlData::recoveryPauseState, recoveryStopsAfter(), recoveryStopsBefore(), recoveryTarget, recoveryTargetAction, RedoStartLSN, RedoStartTLI, XLogRecoveryCtlData::replayEndRecPtr, XLogRecoveryCtlData::replayEndTLI, RmgrCleanup(), RmgrStartup(), SendPostmasterSignal(), SetRecoveryPause(), SpinLockAcquire, SpinLockRelease, StandbyMode, timestamptz_to_str(), XLogRecord::xl_info, XLogRecord::xl_rmid, XLOG_CHECKPOINT_REDO, xlog_outdesc(), xlogprefetcher, XLogPrefetcherBeginRead(), xlogreader, XLogReceiptTime, XLogRecoveryCtl, and XLR_INFO_MASK.
Referenced by StartupXLOG().
bool PromoteIsTriggered | ( | void | ) |
Definition at line 4393 of file xlogrecovery.c.
References XLogRecoveryCtlData::info_lck, LocalPromoteIsTriggered, XLogRecoveryCtlData::SharedPromoteIsTriggered, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by PerformRecoveryXLogAction(), pg_wal_replay_pause(), and pg_wal_replay_resume().
void RecoveryRequiresIntParameter | ( | const char * | param_name, |
int | currValue, | ||
int | minValue | ||
) |
Definition at line 4658 of file xlogrecovery.c.
References CheckForStandbyTrigger(), ConditionVariableCancelSleep(), ConditionVariableTimedSleep(), ConfirmRecoveryPaused(), ereport, errcode(), errdetail(), errhint(), errmsg(), FATAL, GetRecoveryPauseState(), HandleStartupProcInterrupts(), HotStandbyActiveInReplay(), LOG, RECOVERY_NOT_PAUSED, XLogRecoveryCtlData::recoveryNotPausedCV, SetRecoveryPause(), WARNING, and XLogRecoveryCtl.
Referenced by CheckRequiredParameterValues().
void RemovePromoteSignalFiles | ( | void | ) |
Definition at line 4453 of file xlogrecovery.c.
References PROMOTE_SIGNAL_FILE.
Referenced by CheckForStandbyTrigger(), and PostmasterMain().
void SetRecoveryPause | ( | bool | recoveryPause | ) |
Definition at line 3092 of file xlogrecovery.c.
References ConditionVariableBroadcast(), XLogRecoveryCtlData::info_lck, RECOVERY_NOT_PAUSED, RECOVERY_PAUSE_REQUESTED, XLogRecoveryCtlData::recoveryNotPausedCV, XLogRecoveryCtlData::recoveryPauseState, SpinLockAcquire, SpinLockRelease, and XLogRecoveryCtl.
Referenced by PerformWalRecovery(), pg_wal_replay_pause(), pg_wal_replay_resume(), RecoveryRequiresIntParameter(), and SetPromoteIsTriggered().
void ShutdownWalRecovery | ( | void | ) |
Definition at line 1608 of file xlogrecovery.c.
References ArchiveRecoveryRequested, close, DisownLatch(), MAXPGPATH, readFile, XLogRecoveryCtlData::recoveryWakeupLatch, snprintf, XLOGDIR, xlogprefetcher, XLogPrefetcherComputeStats(), XLogPrefetcherFree(), xlogreader, XLogReaderFree(), and XLogRecoveryCtl.
Referenced by StartupXLOG().
void StartupRequestWalReceiverRestart | ( | void | ) |
Definition at line 4374 of file xlogrecovery.c.
References currentSource, ereport, errmsg(), LOG, pendingWalRcvRestart, WalRcvRunning(), and XLOG_FROM_STREAM.
Referenced by StartupRereadConfig().
void WakeupRecovery | ( | void | ) |
Definition at line 4477 of file xlogrecovery.c.
References XLogRecoveryCtlData::recoveryWakeupLatch, SetLatch(), and XLogRecoveryCtl.
Referenced by pg_wal_replay_pause(), StartupProcShutdownHandler(), StartupProcSigHupHandler(), StartupProcTriggerHandler(), WalRcvDie(), WalRcvWaitForStartPosition(), and XLogWalRcvFlush().
void xlog_outdesc | ( | StringInfo | buf, |
XLogReaderState * | record | ||
) |
Definition at line 2299 of file xlogrecovery.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), buf, GetRmgr(), RmgrData::rm_desc, RmgrData::rm_identify, RmgrData::rm_name, XLogRecGetInfo, XLogRecGetRmid, and XLR_INFO_MASK.
Referenced by PerformWalRecovery(), rm_redo_error_callback(), and XLogInsertRecord().
void XLogRecoveryShmemInit | ( | void | ) |
Definition at line 458 of file xlogrecovery.c.
References ConditionVariableInit(), XLogRecoveryCtlData::info_lck, InitSharedLatch(), XLogRecoveryCtlData::recoveryNotPausedCV, XLogRecoveryCtlData::recoveryWakeupLatch, ShmemInitStruct(), SpinLockInit, XLogRecoveryCtl, and XLogRecoveryShmemSize().
Referenced by CreateOrAttachShmemStructs().
Size XLogRecoveryShmemSize | ( | void | ) |
Definition at line 447 of file xlogrecovery.c.
References size.
Referenced by CalculateShmemSize(), and XLogRecoveryShmemInit().
void XLogRequestWalReceiverReply | ( | void | ) |
Definition at line 4486 of file xlogrecovery.c.
References doRequestWalReceiverReply.
Referenced by xact_redo_commit().
|
extern |
Definition at line 84 of file xlogrecovery.c.
Referenced by CreateRestartPoint().
|
extern |
Definition at line 96 of file xlogrecovery.c.
|
extern |
Definition at line 97 of file xlogrecovery.c.
|
extern |
Definition at line 294 of file xlogrecovery.c.
Referenced by CheckRecoveryConsistency(), log_invalid_page(), PerformWalRecovery(), PrepareRedoAdd(), recovery_create_dbdir(), recoveryApplyDelay(), recoveryStopsAfter(), and recoveryStopsBefore().
|
extern |
Definition at line 93 of file xlogrecovery.c.
Referenced by recoveryApplyDelay().
|
extern |
Definition at line 89 of file xlogrecovery.c.
Referenced by validateRecoveryParameters().
|
extern |
Definition at line 83 of file xlogrecovery.c.
Referenced by CleanupAfterArchiveRecovery().
|
extern |
Definition at line 82 of file xlogrecovery.c.
Referenced by RestoreArchivedFile(), and validateRecoveryParameters().
|
extern |
Definition at line 85 of file xlogrecovery.c.
Referenced by assign_recovery_target(), assign_recovery_target_lsn(), assign_recovery_target_name(), assign_recovery_target_time(), assign_recovery_target_xid(), getRecoveryStopReason(), InitWalRecovery(), PerformWalRecovery(), recoveryStopsAfter(), recoveryStopsBefore(), and validateRecoveryParameters().
|
extern |
Definition at line 87 of file xlogrecovery.c.
Referenced by PerformWalRecovery(), and validateRecoveryParameters().
|
extern |
Definition at line 86 of file xlogrecovery.c.
Referenced by recoveryStopsAfter(), and recoveryStopsBefore().
|
extern |
Definition at line 92 of file xlogrecovery.c.
Referenced by assign_recovery_target_lsn(), InitWalRecovery(), recoveryStopsAfter(), and recoveryStopsBefore().
|
extern |
Definition at line 91 of file xlogrecovery.c.
Referenced by assign_recovery_target_name(), InitWalRecovery(), and recoveryStopsAfter().
|
extern |
Definition at line 90 of file xlogrecovery.c.
Referenced by InitWalRecovery(), recoveryStopsBefore(), and validateRecoveryParameters().
|
extern |
Definition at line 120 of file xlogrecovery.c.
Referenced by assign_recovery_target_timeline(), validateRecoveryParameters(), and WaitForWALToBecomeAvailable().
|
extern |
Definition at line 122 of file xlogrecovery.c.
Referenced by InitWalRecovery(), rescanLatestTimeLine(), StartupXLOG(), validateRecoveryParameters(), WaitForWALToBecomeAvailable(), and XLogFileReadAnyTLI().
|
extern |
Definition at line 121 of file xlogrecovery.c.
Referenced by assign_recovery_target_timeline(), and validateRecoveryParameters().
|
extern |
Definition at line 88 of file xlogrecovery.c.
Referenced by assign_recovery_target_xid(), InitWalRecovery(), recoveryStopsAfter(), and recoveryStopsBefore().
|
extern |
Definition at line 147 of file xlogrecovery.c.
Referenced by EnableStandbyMode(), FinishWalRecovery(), PerformWalRecovery(), ReadRecord(), RestoreArchivedFile(), update_synced_slots_inactive_since(), WaitForWALToBecomeAvailable(), and XLogPageRead().
|
extern |
Definition at line 98 of file xlogrecovery.c.
Referenced by StartupRereadConfig(), and WaitForWALToBecomeAvailable().