PostgreSQL Source Code git master
|
#include "access/xlogdefs.h"
#include "access/xlogreader.h"
#include "datatype/timestamp.h"
#include "lib/stringinfo.h"
#include "pgtime.h"
#include "storage/block.h"
#include "storage/relfilelocator.h"
Go to the source code of this file.
Data Structures | |
struct | XLogPageHeaderData |
struct | XLogLongPageHeaderData |
struct | xl_parameter_change |
struct | xl_restore_point |
struct | xl_overwrite_contrecord |
struct | xl_end_of_recovery |
struct | XLogRecData |
struct | RmgrData |
Macros | |
#define | XLOG_PAGE_MAGIC 0xD118 /* can be used as WAL version indicator */ |
#define | SizeOfXLogShortPHD MAXALIGN(sizeof(XLogPageHeaderData)) |
#define | SizeOfXLogLongPHD MAXALIGN(sizeof(XLogLongPageHeaderData)) |
#define | XLP_FIRST_IS_CONTRECORD 0x0001 |
#define | XLP_LONG_HEADER 0x0002 |
#define | XLP_BKP_REMOVABLE 0x0004 |
#define | XLP_FIRST_IS_OVERWRITE_CONTRECORD 0x0008 |
#define | XLP_ALL_FLAGS 0x000F |
#define | XLogPageHeaderSize(hdr) (((hdr)->xlp_info & XLP_LONG_HEADER) ? SizeOfXLogLongPHD : SizeOfXLogShortPHD) |
#define | WalSegMinSize 1024 * 1024 |
#define | WalSegMaxSize 1024 * 1024 * 1024 |
#define | DEFAULT_MIN_WAL_SEGS 5 |
#define | DEFAULT_MAX_WAL_SEGS 64 |
#define | IsPowerOf2(x) (x > 0 && ((x) & ((x)-1)) == 0) |
#define | IsValidWalSegSize(size) |
#define | XLogSegmentsPerXLogId(wal_segsz_bytes) (UINT64CONST(0x100000000) / (wal_segsz_bytes)) |
#define | XLogSegNoOffsetToRecPtr(segno, offset, wal_segsz_bytes, dest) (dest) = (segno) * (wal_segsz_bytes) + (offset) |
#define | XLogSegmentOffset(xlogptr, wal_segsz_bytes) ((xlogptr) & ((wal_segsz_bytes) - 1)) |
#define | XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes) logSegNo = (xlrp) / (wal_segsz_bytes) |
#define | XLByteToPrevSeg(xlrp, logSegNo, wal_segsz_bytes) logSegNo = ((xlrp) - 1) / (wal_segsz_bytes) |
#define | XLogMBVarToSegs(mbvar, wal_segsz_bytes) ((mbvar) / ((wal_segsz_bytes) / (1024 * 1024))) |
#define | XLByteInSeg(xlrp, logSegNo, wal_segsz_bytes) (((xlrp) / (wal_segsz_bytes)) == (logSegNo)) |
#define | XLByteInPrevSeg(xlrp, logSegNo, wal_segsz_bytes) ((((xlrp) - 1) / (wal_segsz_bytes)) == (logSegNo)) |
#define | XRecOffIsValid(xlrp) ((xlrp) % XLOG_BLCKSZ >= SizeOfXLogShortPHD) |
#define | XLOGDIR "pg_wal" |
#define | XLOG_CONTROL_FILE "global/pg_control" |
#define | MAXFNAMELEN 64 |
#define | XLOG_FNAME_LEN 24 |
Typedefs | |
typedef struct XLogPageHeaderData | XLogPageHeaderData |
typedef XLogPageHeaderData * | XLogPageHeader |
typedef struct XLogLongPageHeaderData | XLogLongPageHeaderData |
typedef XLogLongPageHeaderData * | XLogLongPageHeader |
typedef struct xl_parameter_change | xl_parameter_change |
typedef struct xl_restore_point | xl_restore_point |
typedef struct xl_overwrite_contrecord | xl_overwrite_contrecord |
typedef struct xl_end_of_recovery | xl_end_of_recovery |
typedef struct XLogRecData | XLogRecData |
typedef struct RmgrData | RmgrData |
Enumerations | |
enum | RecoveryTargetAction { RECOVERY_TARGET_ACTION_PAUSE , RECOVERY_TARGET_ACTION_PROMOTE , RECOVERY_TARGET_ACTION_SHUTDOWN } |
Functions | |
static void | XLogFileName (char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes) |
static void | XLogFileNameById (char *fname, TimeLineID tli, uint32 log, uint32 seg) |
static bool | IsXLogFileName (const char *fname) |
static bool | IsPartialXLogFileName (const char *fname) |
static void | XLogFromFileName (const char *fname, TimeLineID *tli, XLogSegNo *logSegNo, int wal_segsz_bytes) |
static void | XLogFilePath (char *path, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes) |
static void | TLHistoryFileName (char *fname, TimeLineID tli) |
static bool | IsTLHistoryFileName (const char *fname) |
static void | TLHistoryFilePath (char *path, TimeLineID tli) |
static void | StatusFilePath (char *path, const char *xlog, const char *suffix) |
static void | BackupHistoryFileName (char *fname, TimeLineID tli, XLogSegNo logSegNo, XLogRecPtr startpoint, int wal_segsz_bytes) |
static bool | IsBackupHistoryFileName (const char *fname) |
static void | BackupHistoryFilePath (char *path, TimeLineID tli, XLogSegNo logSegNo, XLogRecPtr startpoint, int wal_segsz_bytes) |
void | RmgrStartup (void) |
void | RmgrCleanup (void) |
void | RmgrNotFound (RmgrId rmid) |
void | RegisterCustomRmgr (RmgrId rmid, const RmgrData *rmgr) |
static bool | RmgrIdExists (RmgrId rmid) |
static RmgrData | GetRmgr (RmgrId rmid) |
pg_time_t | GetLastSegSwitchData (XLogRecPtr *lastSwitchLSN) |
XLogRecPtr | RequestXLogSwitch (bool mark_unimportant) |
void | GetOldestRestartPoint (XLogRecPtr *oldrecptr, TimeLineID *oldtli) |
void | XLogRecGetBlockRefInfo (XLogReaderState *record, bool pretty, bool detailed_format, StringInfo buf, uint32 *fpi_len) |
Variables | |
PGDLLIMPORT RmgrData | RmgrTable [] |
PGDLLIMPORT bool | ArchiveRecoveryRequested |
PGDLLIMPORT bool | InArchiveRecovery |
PGDLLIMPORT bool | StandbyMode |
PGDLLIMPORT char * | recoveryRestoreCommand |
#define DEFAULT_MAX_WAL_SEGS 64 |
Definition at line 92 of file xlog_internal.h.
#define DEFAULT_MIN_WAL_SEGS 5 |
Definition at line 91 of file xlog_internal.h.
Definition at line 95 of file xlog_internal.h.
#define IsValidWalSegSize | ( | size | ) |
Definition at line 96 of file xlog_internal.h.
#define MAXFNAMELEN 64 |
Definition at line 156 of file xlog_internal.h.
#define SizeOfXLogLongPHD MAXALIGN(sizeof(XLogLongPageHeaderData)) |
Definition at line 69 of file xlog_internal.h.
#define SizeOfXLogShortPHD MAXALIGN(sizeof(XLogPageHeaderData)) |
Definition at line 52 of file xlog_internal.h.
#define WalSegMaxSize 1024 * 1024 * 1024 |
Definition at line 89 of file xlog_internal.h.
#define WalSegMinSize 1024 * 1024 |
Definition at line 88 of file xlog_internal.h.
#define XLByteInPrevSeg | ( | xlrp, | |
logSegNo, | |||
wal_segsz_bytes | |||
) | ((((xlrp) - 1) / (wal_segsz_bytes)) == (logSegNo)) |
Definition at line 139 of file xlog_internal.h.
#define XLByteInSeg | ( | xlrp, | |
logSegNo, | |||
wal_segsz_bytes | |||
) | (((xlrp) / (wal_segsz_bytes)) == (logSegNo)) |
Definition at line 136 of file xlog_internal.h.
#define XLByteToPrevSeg | ( | xlrp, | |
logSegNo, | |||
wal_segsz_bytes | |||
) | logSegNo = ((xlrp) - 1) / (wal_segsz_bytes) |
Definition at line 120 of file xlog_internal.h.
#define XLByteToSeg | ( | xlrp, | |
logSegNo, | |||
wal_segsz_bytes | |||
) | logSegNo = (xlrp) / (wal_segsz_bytes) |
Definition at line 117 of file xlog_internal.h.
#define XLOG_CONTROL_FILE "global/pg_control" |
Definition at line 150 of file xlog_internal.h.
#define XLOG_FNAME_LEN 24 |
Definition at line 159 of file xlog_internal.h.
#define XLOG_PAGE_MAGIC 0xD118 /* can be used as WAL version indicator */ |
Definition at line 34 of file xlog_internal.h.
#define XLOGDIR "pg_wal" |
Definition at line 149 of file xlog_internal.h.
#define XLogMBVarToSegs | ( | mbvar, | |
wal_segsz_bytes | |||
) | ((mbvar) / ((wal_segsz_bytes) / (1024 * 1024))) |
Definition at line 127 of file xlog_internal.h.
#define XLogPageHeaderSize | ( | hdr | ) | (((hdr)->xlp_info & XLP_LONG_HEADER) ? SizeOfXLogLongPHD : SizeOfXLogShortPHD) |
Definition at line 84 of file xlog_internal.h.
#define XLogSegmentOffset | ( | xlogptr, | |
wal_segsz_bytes | |||
) | ((xlogptr) & ((wal_segsz_bytes) - 1)) |
Definition at line 106 of file xlog_internal.h.
#define XLogSegmentsPerXLogId | ( | wal_segsz_bytes | ) | (UINT64CONST(0x100000000) / (wal_segsz_bytes)) |
Definition at line 100 of file xlog_internal.h.
#define XLogSegNoOffsetToRecPtr | ( | segno, | |
offset, | |||
wal_segsz_bytes, | |||
dest | |||
) | (dest) = (segno) * (wal_segsz_bytes) + (offset) |
Definition at line 103 of file xlog_internal.h.
#define XLP_ALL_FLAGS 0x000F |
Definition at line 82 of file xlog_internal.h.
#define XLP_BKP_REMOVABLE 0x0004 |
Definition at line 78 of file xlog_internal.h.
#define XLP_FIRST_IS_CONTRECORD 0x0001 |
Definition at line 74 of file xlog_internal.h.
#define XLP_FIRST_IS_OVERWRITE_CONTRECORD 0x0008 |
Definition at line 80 of file xlog_internal.h.
#define XLP_LONG_HEADER 0x0002 |
Definition at line 76 of file xlog_internal.h.
#define XRecOffIsValid | ( | xlrp | ) | ((xlrp) % XLOG_BLCKSZ >= SizeOfXLogShortPHD) |
Definition at line 143 of file xlog_internal.h.
typedef struct xl_end_of_recovery xl_end_of_recovery |
typedef struct xl_overwrite_contrecord xl_overwrite_contrecord |
typedef struct xl_parameter_change xl_parameter_change |
typedef struct xl_restore_point xl_restore_point |
typedef XLogLongPageHeaderData* XLogLongPageHeader |
Definition at line 71 of file xlog_internal.h.
typedef struct XLogLongPageHeaderData XLogLongPageHeaderData |
typedef XLogPageHeaderData* XLogPageHeader |
Definition at line 54 of file xlog_internal.h.
typedef struct XLogPageHeaderData XLogPageHeaderData |
typedef struct XLogRecData XLogRecData |
enum RecoveryTargetAction |
Enumerator | |
---|---|
RECOVERY_TARGET_ACTION_PAUSE | |
RECOVERY_TARGET_ACTION_PROMOTE | |
RECOVERY_TARGET_ACTION_SHUTDOWN |
Definition at line 322 of file xlog_internal.h.
|
inlinestatic |
Definition at line 244 of file xlog_internal.h.
References MAXFNAMELEN, snprintf, XLogSegmentOffset, and XLogSegmentsPerXLogId.
Referenced by do_pg_backup_stop().
|
inlinestatic |
Definition at line 261 of file xlog_internal.h.
References MAXPGPATH, snprintf, XLOGDIR, XLogSegmentOffset, and XLogSegmentsPerXLogId.
Referenced by do_pg_backup_stop().
pg_time_t GetLastSegSwitchData | ( | XLogRecPtr * | lastSwitchLSN | ) |
Definition at line 6585 of file xlog.c.
References XLogCtlData::lastSegSwitchLSN, XLogCtlData::lastSegSwitchTime, LW_SHARED, LWLockAcquire(), LWLockRelease(), and XLogCtl.
Referenced by CheckArchiveTimeout().
void GetOldestRestartPoint | ( | XLogRecPtr * | oldrecptr, |
TimeLineID * | oldtli | ||
) |
Definition at line 9463 of file xlog.c.
References ControlFileData::checkPointCopy, ControlFile, LW_SHARED, LWLockAcquire(), LWLockRelease(), CheckPoint::redo, and CheckPoint::ThisTimeLineID.
Referenced by ExecuteRecoveryCommand(), and RestoreArchivedFile().
Definition at line 376 of file xlog_internal.h.
References RmgrIdExists(), RmgrNotFound(), RmgrTable, and unlikely.
Referenced by ApplyWalRecord(), check_wal_consistency_checking(), GetWALBlockInfo(), GetWALRecordInfo(), GetXLogSummaryStats(), LogicalDecodingProcessRecord(), verifyBackupPageConsistency(), and xlog_outdesc().
|
inlinestatic |
Definition at line 253 of file xlog_internal.h.
References XLOG_FNAME_LEN.
Referenced by CleanupBackupHistory(), CleanupPriorWALFiles(), and SetWALFileNameForCleanup().
|
inlinestatic |
Definition at line 192 of file xlog_internal.h.
References XLOG_FNAME_LEN.
Referenced by CleanupPriorWALFiles(), FindEndOfXLOG(), KillExistingXLOG(), RemoveOldXlogFiles(), and SetWALFileNameForCleanup().
|
inlinestatic |
Definition at line 224 of file xlog_internal.h.
Referenced by perform_base_backup(), ready_file_comparator(), and XLogArchiveNotify().
|
inlinestatic |
Definition at line 180 of file xlog_internal.h.
References XLOG_FNAME_LEN.
Referenced by CleanupPriorWALFiles(), FindEndOfXLOG(), KillExistingXLOG(), perform_base_backup(), pg_split_walfile_name(), RemoveNonParentXlogFiles(), RemoveOldXlogFiles(), search_directory(), SetWALFileNameForCleanup(), and XLogGetOldestSegno().
Definition at line 107 of file rmgr.c.
References ereport, errdetail(), errhint(), errmsg(), ERROR, LOG, pg_strcasecmp(), process_shared_preload_libraries_in_progress, RM_MAX_CUSTOM_ID, RM_MAX_ID, RM_MIN_CUSTOM_ID, RmgrData::rm_name, RmgrIdExists(), RmgrIdIsCustom(), and RmgrTable.
Referenced by _PG_init().
XLogRecPtr RequestXLogSwitch | ( | bool | mark_unimportant | ) |
Definition at line 8060 of file xlog.c.
References XLOG_MARK_UNIMPORTANT, XLOG_SWITCH, XLogBeginInsert(), XLogInsert(), and XLogSetRecordFlags().
Referenced by CheckArchiveTimeout(), do_pg_backup_start(), do_pg_backup_stop(), pg_switch_wal(), and ShutdownXLOG().
void RmgrCleanup | ( | void | ) |
Definition at line 74 of file rmgr.c.
References RmgrData::rm_cleanup, RM_MAX_ID, RmgrIdExists(), and RmgrTable.
Referenced by PerformWalRecovery().
|
inlinestatic |
Definition at line 370 of file xlog_internal.h.
References RmgrData::rm_name, and RmgrTable.
Referenced by check_wal_consistency_checking(), GetRmgr(), GetXLogSummaryStats(), RegisterCustomRmgr(), RmgrCleanup(), and RmgrStartup().
void RmgrNotFound | ( | RmgrId | rmid | ) |
void RmgrStartup | ( | void | ) |
Definition at line 58 of file rmgr.c.
References RM_MAX_ID, RmgrData::rm_startup, RmgrIdExists(), and RmgrTable.
Referenced by PerformWalRecovery().
|
inlinestatic |
Definition at line 238 of file xlog_internal.h.
References MAXPGPATH, snprintf, and XLOGDIR.
Referenced by perform_base_backup(), pgarch_archiveDone(), pgarch_ArchiverCopyLoop(), pgarch_readyXlog(), XLogArchiveCheckDone(), XLogArchiveCleanup(), XLogArchiveForceDone(), XLogArchiveIsBusy(), XLogArchiveIsReady(), XLogArchiveIsReadyOrDone(), and XLogArchiveNotify().
|
inlinestatic |
Definition at line 218 of file xlog_internal.h.
References MAXFNAMELEN, and snprintf.
Referenced by existsTimeLineHistory(), existsTimeLineHistoryFile(), readTimeLineHistory(), restoreTimeLineHistoryFiles(), SendTimeLineHistory(), WalRcvFetchTimeLineHistoryFiles(), writeTimeLineHistory(), and writeTimeLineHistoryFile().
|
inlinestatic |
Definition at line 232 of file xlog_internal.h.
References MAXPGPATH, snprintf, and XLOGDIR.
Referenced by existsTimeLineHistory(), getTimelineHistory(), readTimeLineHistory(), SendTimeLineHistory(), writeTimeLineHistory(), and writeTimeLineHistoryFile().
|
inlinestatic |
Definition at line 166 of file xlog_internal.h.
References MAXFNAMELEN, snprintf, and XLogSegmentsPerXLogId.
Referenced by assign_wal_sync_method(), build_backup_content(), CheckXLogRemoved(), CleanupAfterArchiveRecovery(), createBackupLabel(), do_pg_backup_stop(), ExecuteRecoveryCommand(), findLastCheckpoint(), issue_xlog_fsync(), main(), open_walfile(), perform_base_backup(), pg_control_checkpoint(), pg_walfile_name(), pg_walfile_name_offset(), PrintNewControlValues(), ReadRecord(), RemoveNonParentXlogFiles(), RemoveOldXlogFiles(), RestoreArchivedFile(), SimpleXLogPageRead(), WALDumpOpenSegment(), WALDumpReadPage(), WALReadRaiseError(), WalReceiverMain(), WalSndSegmentOpen(), XLogArchiveNotifySeg(), XLogFileClose(), XLogFileRead(), XLogInitNewTimeline(), XLogPageRead(), XLogReaderValidatePageHeader(), XLogWalRcvClose(), XLogWalRcvWrite(), and XLogWrite().
|
inlinestatic |
Definition at line 174 of file xlog_internal.h.
References MAXFNAMELEN, and snprintf.
Referenced by SetWALFileNameForCleanup().
|
inlinestatic |
Definition at line 210 of file xlog_internal.h.
References MAXPGPATH, snprintf, XLOGDIR, and XLogSegmentsPerXLogId.
Referenced by CleanupAfterArchiveRecovery(), InstallXLogFileSegment(), wal_segment_open(), WalSndSegmentOpen(), WriteEmptyXLOG(), XLogFileCopy(), XLogFileInitInternal(), XLogFileOpen(), XLogFileRead(), and XLogFileReadAnyTLI().
|
inlinestatic |
Definition at line 200 of file xlog_internal.h.
References XLogSegmentsPerXLogId.
Referenced by FindEndOfXLOG(), FindStreamingStart(), main(), perform_base_backup(), pg_split_walfile_name(), UpdateLastRemovedPtr(), and XLogGetOldestSegno().
void XLogRecGetBlockRefInfo | ( | XLogReaderState * | record, |
bool | pretty, | ||
bool | detailed_format, | ||
StringInfo | buf, | ||
uint32 * | fpi_len | ||
) |
Definition at line 231 of file xlogdesc.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, BKPIMAGE_COMPRESS_LZ4, BKPIMAGE_COMPRESS_PGLZ, BKPIMAGE_COMPRESS_ZSTD, BKPIMAGE_COMPRESSED, buf, RelFileLocator::dbOid, forkNames, MAIN_FORKNUM, RelFileLocator::relNumber, RelFileLocator::spcOid, XLogRecBlockImageApply, XLogRecGetBlock, XLogRecGetBlockTagExtended(), XLogRecHasBlockImage, and XLogRecMaxBlockId.
Referenced by GetWALRecordInfo(), and XLogDumpDisplayRecord().
|
extern |
Definition at line 137 of file xlogrecovery.c.
Referenced by CheckRequiredParameterValues(), existsTimeLineHistory(), FinishWalRecovery(), InitWalRecovery(), PerformRecoveryXLogAction(), PerformWalRecovery(), ReadRecord(), readRecoverySignalFile(), readTimeLineHistory(), recoveryApplyDelay(), recoveryStopsAfter(), recoveryStopsBefore(), RestoreArchivedFile(), ShutdownWalRecovery(), StartupXLOG(), validateRecoveryParameters(), writeTimeLineHistory(), xlog_redo(), and XLogPageRead().
|
extern |
Definition at line 138 of file xlogrecovery.c.
Referenced by CheckRecoveryConsistency(), FinishWalRecovery(), InitWalRecovery(), ReadRecord(), StartupXLOG(), WaitForWALToBecomeAvailable(), and xlog_redo().
|
extern |
Definition at line 82 of file xlogrecovery.c.
|
extern |
Definition at line 50 of file rmgr.c.
Referenced by GetRmgr(), RegisterCustomRmgr(), RmgrCleanup(), RmgrIdExists(), and RmgrStartup().
|
extern |
Definition at line 147 of file xlogrecovery.c.