PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
xlogrecovery.h
Go to the documentation of this file.
1/*
2 * xlogrecovery.h
3 *
4 * Functions for WAL recovery and standby mode
5 *
6 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/access/xlogrecovery.h
10 */
11#ifndef XLOGRECOVERY_H
12#define XLOGRECOVERY_H
13
14#include "access/xlogreader.h"
15#include "catalog/pg_control.h"
16#include "lib/stringinfo.h"
17#include "utils/timestamp.h"
18
19/*
20 * Recovery target type.
21 * Only set during a Point in Time recovery, not when in standby mode.
22 */
23typedef enum
24{
32
33/*
34 * Recovery target TimeLine goal
35 */
36typedef enum
37{
42
43/* Recovery pause states */
45{
46 RECOVERY_NOT_PAUSED, /* pause not requested */
47 RECOVERY_PAUSE_REQUESTED, /* pause requested, but not yet paused */
48 RECOVERY_PAUSED, /* recovery is paused */
50
51/* User-settable GUC parameters */
55extern PGDLLIMPORT char *PrimaryConnInfo;
56extern PGDLLIMPORT char *PrimarySlotName;
60
61/* indirectly set via GUC system */
65extern PGDLLIMPORT const char *recoveryTargetName;
72
73/* Have we already reached a consistent database state? */
75
76/* Are we currently in standby mode? */
77extern PGDLLIMPORT bool StandbyMode;
78
79extern Size XLogRecoveryShmemSize(void);
80extern void XLogRecoveryShmemInit(void);
81
83 bool *wasShutdown_ptr, bool *haveBackupLabel_ptr,
84 bool *haveTblspcMap_ptr);
85extern void PerformWalRecovery(void);
86
87/*
88 * FinishWalRecovery() returns this. It contains information about the point
89 * where recovery ended, and why it ended.
90 */
91typedef struct
92{
93 /*
94 * Information about the last valid or applied record, after which new WAL
95 * can be appended. 'lastRec' is the position where the last record
96 * starts, and 'endOfLog' is its end. 'lastPage' is a copy of the last
97 * partial page that contains endOfLog (or NULL if endOfLog is exactly at
98 * page boundary). 'lastPageBeginPtr' is the position where the last page
99 * begins.
100 *
101 * endOfLogTLI is the TLI in the filename of the XLOG segment containing
102 * the last applied record. It could be different from lastRecTLI, if
103 * there was a timeline switch in that segment, and we were reading the
104 * old WAL from a segment belonging to a higher timeline.
105 */
106 XLogRecPtr lastRec; /* start of last valid or applied record */
108 XLogRecPtr endOfLog; /* end of last valid or applied record */
110
111 XLogRecPtr lastPageBeginPtr; /* LSN of page that contains endOfLog */
112 char *lastPage; /* copy of the last page, up to endOfLog */
113
114 /*
115 * abortedRecPtr is the start pointer of a broken record at end of WAL
116 * when recovery completes; missingContrecPtr is the location of the first
117 * contrecord that went missing. See CreateOverwriteContrecordRecord for
118 * details.
119 */
122
123 /* short human-readable string describing why recovery ended */
125
126 /*
127 * If standby or recovery signal file was found, these flags are set
128 * accordingly.
129 */
133
135extern void ShutdownWalRecovery(void);
136extern void RemovePromoteSignalFiles(void);
137
138extern bool HotStandbyActive(void);
139extern XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI);
141extern void SetRecoveryPause(bool recoveryPause);
142extern void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream);
143extern TimestampTz GetLatestXTime(void);
145extern XLogRecPtr GetCurrentReplayRecPtr(TimeLineID *replayEndTLI);
146
147extern bool PromoteIsTriggered(void);
148extern bool CheckPromoteSignal(void);
149extern void WakeupRecovery(void);
150
151extern void StartupRequestWalReceiverRestart(void);
152extern void XLogRequestWalReceiverReply(void);
153
154extern void RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue);
155
156extern void xlog_outdesc(StringInfo buf, XLogReaderState *record);
157
158#endif /* XLOGRECOVERY_H */
#define PGDLLIMPORT
Definition: c.h:1274
uint32 TransactionId
Definition: c.h:606
size_t Size
Definition: c.h:559
int64 TimestampTz
Definition: timestamp.h:39
static char * buf
Definition: pg_test_fsync.c:72
XLogRecPtr lastPageBeginPtr
Definition: xlogrecovery.h:111
XLogRecPtr abortedRecPtr
Definition: xlogrecovery.h:120
XLogRecPtr missingContrecPtr
Definition: xlogrecovery.h:121
TimeLineID endOfLogTLI
Definition: xlogrecovery.h:109
static ControlFileData * ControlFile
Definition: xlog.c:574
uint64 XLogRecPtr
Definition: xlogdefs.h:21
uint32 TimeLineID
Definition: xlogdefs.h:59
bool HotStandbyActive(void)
PGDLLIMPORT int recovery_min_apply_delay
Definition: xlogrecovery.c:93
void ShutdownWalRecovery(void)
PGDLLIMPORT TimeLineID recoveryTargetTLIRequested
Definition: xlogrecovery.c:121
PGDLLIMPORT TimeLineID recoveryTargetTLI
Definition: xlogrecovery.c:122
PGDLLIMPORT TimestampTz recoveryTargetTime
Definition: xlogrecovery.c:90
void StartupRequestWalReceiverRestart(void)
void RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue)
void PerformWalRecovery(void)
bool CheckPromoteSignal(void)
PGDLLIMPORT char * PrimarySlotName
Definition: xlogrecovery.c:97
void SetRecoveryPause(bool recoveryPause)
XLogRecPtr GetCurrentReplayRecPtr(TimeLineID *replayEndTLI)
RecoveryTargetType
Definition: xlogrecovery.h:24
@ RECOVERY_TARGET_IMMEDIATE
Definition: xlogrecovery.h:30
@ RECOVERY_TARGET_TIME
Definition: xlogrecovery.h:27
@ RECOVERY_TARGET_UNSET
Definition: xlogrecovery.h:25
@ RECOVERY_TARGET_XID
Definition: xlogrecovery.h:26
@ RECOVERY_TARGET_LSN
Definition: xlogrecovery.h:29
@ RECOVERY_TARGET_NAME
Definition: xlogrecovery.h:28
void WakeupRecovery(void)
void xlog_outdesc(StringInfo buf, XLogReaderState *record)
bool PromoteIsTriggered(void)
TimestampTz GetCurrentChunkReplayStartTime(void)
PGDLLIMPORT XLogRecPtr recoveryTargetLSN
Definition: xlogrecovery.c:92
PGDLLIMPORT RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlogrecovery.c:120
PGDLLIMPORT bool wal_receiver_create_temp_slot
Definition: xlogrecovery.c:98
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream)
PGDLLIMPORT RecoveryTargetType recoveryTarget
Definition: xlogrecovery.c:85
RecoveryTargetTimeLineGoal
Definition: xlogrecovery.h:37
@ RECOVERY_TARGET_TIMELINE_NUMERIC
Definition: xlogrecovery.h:40
@ RECOVERY_TARGET_TIMELINE_CONTROLFILE
Definition: xlogrecovery.h:38
@ RECOVERY_TARGET_TIMELINE_LATEST
Definition: xlogrecovery.h:39
EndOfWalRecoveryInfo * FinishWalRecovery(void)
RecoveryPauseState
Definition: xlogrecovery.h:45
@ RECOVERY_PAUSED
Definition: xlogrecovery.h:48
@ RECOVERY_NOT_PAUSED
Definition: xlogrecovery.h:46
@ RECOVERY_PAUSE_REQUESTED
Definition: xlogrecovery.h:47
PGDLLIMPORT bool StandbyMode
Definition: xlogrecovery.c:147
void InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, bool *haveBackupLabel_ptr, bool *haveTblspcMap_ptr)
Definition: xlogrecovery.c:512
Size XLogRecoveryShmemSize(void)
Definition: xlogrecovery.c:447
PGDLLIMPORT bool recoveryTargetInclusive
Definition: xlogrecovery.c:86
RecoveryPauseState GetRecoveryPauseState(void)
void XLogRecoveryShmemInit(void)
Definition: xlogrecovery.c:458
PGDLLIMPORT char * recoveryEndCommand
Definition: xlogrecovery.c:83
PGDLLIMPORT char * recovery_target_time_string
Definition: xlogrecovery.c:89
TimestampTz GetLatestXTime(void)
void XLogRequestWalReceiverReply(void)
PGDLLIMPORT const char * recoveryTargetName
Definition: xlogrecovery.c:91
PGDLLIMPORT bool reachedConsistency
Definition: xlogrecovery.c:294
void RemovePromoteSignalFiles(void)
PGDLLIMPORT TransactionId recoveryTargetXid
Definition: xlogrecovery.c:88
PGDLLIMPORT char * PrimaryConnInfo
Definition: xlogrecovery.c:96
PGDLLIMPORT char * archiveCleanupCommand
Definition: xlogrecovery.c:84
PGDLLIMPORT char * recoveryRestoreCommand
Definition: xlogrecovery.c:82
PGDLLIMPORT int recoveryTargetAction
Definition: xlogrecovery.c:87