mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Allow read only connections during recovery, known as Hot Standby.
Enabled by recovery_connections = on (default) and forcing archive recovery using a recovery.conf. Recovery processing now emulates the original transactions as they are replayed, providing full locking and MVCC behaviour for read only queries. Recovery must enter consistent state before connections are allowed, so there is a delay, typically short, before connections succeed. Replay of recovering transactions can conflict and in some cases deadlock with queries during recovery; these result in query cancellation after max_standby_delay seconds have expired. Infrastructure changes have minor effects on normal running, though introduce four new types of WAL record. New test mode "make standbycheck" allows regression tests of static command behaviour on a standby server while in recovery. Typical and extreme dynamic behaviours have been checked via code inspection and manual testing. Few port specific behaviours have been utilised, though primary testing has been on Linux only so far. This commit is the basic patch. Additional changes will follow in this release to enhance some aspects of behaviour, notably improved handling of conflicts, deadlock detection and query cancellation. Changes to VACUUM FULL are also required. Simon Riggs, with significant and lengthy review by Heikki Linnakangas, including streamlined redesign of snapshot creation and two-phase commit. Important contributions from Florian Pflug, Mark Kirkwood, Merlin Moncure, Greg Stark, Gianni Ciolli, Gabriele Bartolini, Hannu Krosing, Robert Haas, Tatsuo Ishii, Hiroyuki Yamada plus support and feedback from many other community members.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.144 2009/08/24 02:18:32 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.145 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -130,11 +130,13 @@ extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf,
|
||||
ItemPointerData from,
|
||||
Buffer newbuf, HeapTuple newtup,
|
||||
bool all_visible_cleared, bool new_all_visible_cleared);
|
||||
extern XLogRecPtr log_heap_cleanup_info(RelFileNode rnode,
|
||||
TransactionId latestRemovedXid);
|
||||
extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
|
||||
OffsetNumber *redirected, int nredirected,
|
||||
OffsetNumber *nowdead, int ndead,
|
||||
OffsetNumber *nowunused, int nunused,
|
||||
bool redirect_move);
|
||||
TransactionId latestRemovedXid, bool redirect_move);
|
||||
extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer,
|
||||
TransactionId cutoff_xid,
|
||||
OffsetNumber *offsets, int offcnt);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.107 2009/06/11 14:49:08 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.108 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -580,6 +580,7 @@ typedef HeapTupleData *HeapTuple;
|
||||
#define XLOG_HEAP2_FREEZE 0x00
|
||||
#define XLOG_HEAP2_CLEAN 0x10
|
||||
#define XLOG_HEAP2_CLEAN_MOVE 0x20
|
||||
#define XLOG_HEAP2_CLEANUP_INFO 0x30
|
||||
|
||||
/*
|
||||
* All what we need to find changed tuple
|
||||
@@ -668,6 +669,7 @@ typedef struct xl_heap_clean
|
||||
{
|
||||
RelFileNode node;
|
||||
BlockNumber block;
|
||||
TransactionId latestRemovedXid;
|
||||
uint16 nredirected;
|
||||
uint16 ndead;
|
||||
/* OFFSET NUMBERS FOLLOW */
|
||||
@@ -675,6 +677,19 @@ typedef struct xl_heap_clean
|
||||
|
||||
#define SizeOfHeapClean (offsetof(xl_heap_clean, ndead) + sizeof(uint16))
|
||||
|
||||
/*
|
||||
* Cleanup_info is required in some cases during a lazy VACUUM.
|
||||
* Used for reporting the results of HeapTupleHeaderAdvanceLatestRemovedXid()
|
||||
* see vacuumlazy.c for full explanation
|
||||
*/
|
||||
typedef struct xl_heap_cleanup_info
|
||||
{
|
||||
RelFileNode node;
|
||||
TransactionId latestRemovedXid;
|
||||
} xl_heap_cleanup_info;
|
||||
|
||||
#define SizeOfHeapCleanupInfo (sizeof(xl_heap_cleanup_info))
|
||||
|
||||
/* This is for replacing a page's contents in toto */
|
||||
/* NB: this is used for indexes as well as heaps */
|
||||
typedef struct xl_heap_newpage
|
||||
@@ -718,6 +733,9 @@ typedef struct xl_heap_freeze
|
||||
|
||||
#define SizeOfHeapFreeze (offsetof(xl_heap_freeze, cutoff_xid) + sizeof(TransactionId))
|
||||
|
||||
extern void HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
|
||||
TransactionId *latestRemovedXid);
|
||||
|
||||
/* HeapTupleHeader functions implemented in utils/time/combocid.c */
|
||||
extern CommandId HeapTupleHeaderGetCmin(HeapTupleHeader tup);
|
||||
extern CommandId HeapTupleHeaderGetCmax(HeapTupleHeader tup);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.125 2009/07/29 20:56:19 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.126 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -214,12 +214,13 @@ typedef struct BTMetaPageData
|
||||
#define XLOG_BTREE_SPLIT_R 0x40 /* as above, new item on right */
|
||||
#define XLOG_BTREE_SPLIT_L_ROOT 0x50 /* add tuple with split of root */
|
||||
#define XLOG_BTREE_SPLIT_R_ROOT 0x60 /* as above, new item on right */
|
||||
#define XLOG_BTREE_DELETE 0x70 /* delete leaf index tuple */
|
||||
#define XLOG_BTREE_DELETE 0x70 /* delete leaf index tuples for a page */
|
||||
#define XLOG_BTREE_DELETE_PAGE 0x80 /* delete an entire page */
|
||||
#define XLOG_BTREE_DELETE_PAGE_META 0x90 /* same, and update metapage */
|
||||
#define XLOG_BTREE_NEWROOT 0xA0 /* new root page */
|
||||
#define XLOG_BTREE_DELETE_PAGE_HALF 0xB0 /* page deletion that makes
|
||||
* parent half-dead */
|
||||
#define XLOG_BTREE_VACUUM 0xC0 /* delete entries on a page during vacuum */
|
||||
|
||||
/*
|
||||
* All that we need to find changed index tuple
|
||||
@@ -306,16 +307,53 @@ typedef struct xl_btree_split
|
||||
/*
|
||||
* This is what we need to know about delete of individual leaf index tuples.
|
||||
* The WAL record can represent deletion of any number of index tuples on a
|
||||
* single index page.
|
||||
* single index page when *not* executed by VACUUM.
|
||||
*/
|
||||
typedef struct xl_btree_delete
|
||||
{
|
||||
RelFileNode node;
|
||||
BlockNumber block;
|
||||
TransactionId latestRemovedXid;
|
||||
int numItems; /* number of items in the offset array */
|
||||
|
||||
/* TARGET OFFSET NUMBERS FOLLOW AT THE END */
|
||||
} xl_btree_delete;
|
||||
|
||||
#define SizeOfBtreeDelete (offsetof(xl_btree_delete, block) + sizeof(BlockNumber))
|
||||
#define SizeOfBtreeDelete (offsetof(xl_btree_delete, latestRemovedXid) + sizeof(TransactionId))
|
||||
|
||||
/*
|
||||
* This is what we need to know about vacuum of individual leaf index tuples.
|
||||
* The WAL record can represent deletion of any number of index tuples on a
|
||||
* single index page when executed by VACUUM.
|
||||
*
|
||||
* The correctness requirement for applying these changes during recovery is
|
||||
* that we must do one of these two things for every block in the index:
|
||||
* * lock the block for cleanup and apply any required changes
|
||||
* * EnsureBlockUnpinned()
|
||||
* The purpose of this is to ensure that no index scans started before we
|
||||
* finish scanning the index are still running by the time we begin to remove
|
||||
* heap tuples.
|
||||
*
|
||||
* Any changes to any one block are registered on just one WAL record. All
|
||||
* blocks that we need to run EnsureBlockUnpinned() before we touch the changed
|
||||
* block are also given on this record as a variable length array. The array
|
||||
* is compressed by way of storing an array of block ranges, rather than an
|
||||
* actual array of blockids.
|
||||
*
|
||||
* Note that the *last* WAL record in any vacuum of an index is allowed to
|
||||
* have numItems == 0. All other WAL records must have numItems > 0.
|
||||
*/
|
||||
typedef struct xl_btree_vacuum
|
||||
{
|
||||
RelFileNode node;
|
||||
BlockNumber block;
|
||||
BlockNumber lastBlockVacuumed;
|
||||
int numItems; /* number of items in the offset array */
|
||||
|
||||
/* TARGET OFFSET NUMBERS FOLLOW */
|
||||
} xl_btree_vacuum;
|
||||
|
||||
#define SizeOfBtreeVacuum (offsetof(xl_btree_vacuum, lastBlockVacuumed) + sizeof(BlockNumber))
|
||||
|
||||
/*
|
||||
* This is what we need to know about deletion of a btree page. The target
|
||||
@@ -537,7 +575,8 @@ extern void _bt_relbuf(Relation rel, Buffer buf);
|
||||
extern void _bt_pageinit(Page page, Size size);
|
||||
extern bool _bt_page_recyclable(Page page);
|
||||
extern void _bt_delitems(Relation rel, Buffer buf,
|
||||
OffsetNumber *itemnos, int nitems);
|
||||
OffsetNumber *itemnos, int nitems, bool isVacuum,
|
||||
BlockNumber lastBlockVacuumed);
|
||||
extern int _bt_pagedel(Relation rel, Buffer buf,
|
||||
BTStack stack, bool vacuum_full);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.67 2009/01/01 17:23:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.68 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -68,6 +68,7 @@ typedef struct IndexScanDescData
|
||||
/* signaling to index AM about killing index tuples */
|
||||
bool kill_prior_tuple; /* last-returned tuple is dead */
|
||||
bool ignore_killed_tuples; /* do not return killed entries */
|
||||
bool xactStartedInRecovery; /* prevents killing/seeing killed tuples */
|
||||
|
||||
/* index access method's private state */
|
||||
void *opaque; /* access-method-specific info */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Resource managers definition
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.19 2008/11/19 10:34:52 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.20 2009/12/19 01:32:42 sriggs Exp $
|
||||
*/
|
||||
#ifndef RMGR_H
|
||||
#define RMGR_H
|
||||
@@ -23,6 +23,7 @@ typedef uint8 RmgrId;
|
||||
#define RM_DBASE_ID 4
|
||||
#define RM_TBLSPC_ID 5
|
||||
#define RM_MULTIXACT_ID 6
|
||||
#define RM_STANDBY_ID 8
|
||||
#define RM_HEAP2_ID 9
|
||||
#define RM_HEAP_ID 10
|
||||
#define RM_BTREE_ID 11
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/subtrans.h,v 1.12 2009/01/01 17:23:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/subtrans.h,v 1.13 2009/12/19 01:32:42 sriggs Exp $
|
||||
*/
|
||||
#ifndef SUBTRANS_H
|
||||
#define SUBTRANS_H
|
||||
@@ -14,7 +14,7 @@
|
||||
/* Number of SLRU buffers to use for subtrans */
|
||||
#define NUM_SUBTRANS_BUFFERS 32
|
||||
|
||||
extern void SubTransSetParent(TransactionId xid, TransactionId parent);
|
||||
extern void SubTransSetParent(TransactionId xid, TransactionId parent, bool overwriteOK);
|
||||
extern TransactionId SubTransGetParent(TransactionId xid);
|
||||
extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/transam.h,v 1.70 2009/09/01 04:46:49 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/transam.h,v 1.71 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -129,6 +129,9 @@ typedef VariableCacheData *VariableCache;
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
/* in transam/xact.c */
|
||||
extern bool TransactionStartedDuringRecovery(void);
|
||||
|
||||
/* in transam/varsup.c */
|
||||
extern PGDLLIMPORT VariableCache ShmemVariableCache;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/twophase.h,v 1.12 2009/11/23 09:58:36 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/twophase.h,v 1.13 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,8 +40,10 @@ extern GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid,
|
||||
|
||||
extern void StartPrepare(GlobalTransaction gxact);
|
||||
extern void EndPrepare(GlobalTransaction gxact);
|
||||
extern bool StandbyTransactionIdIsPrepared(TransactionId xid);
|
||||
|
||||
extern TransactionId PrescanPreparedTransactions(void);
|
||||
extern TransactionId PrescanPreparedTransactions(TransactionId **xids_p,
|
||||
int *nxids_p);
|
||||
extern void RecoverPreparedTransactions(void);
|
||||
|
||||
extern void RecreateTwoPhaseFile(TransactionId xid, void *content, int len);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/twophase_rmgr.h,v 1.9 2009/11/23 09:58:36 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/twophase_rmgr.h,v 1.10 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -23,15 +23,15 @@ typedef uint8 TwoPhaseRmgrId;
|
||||
*/
|
||||
#define TWOPHASE_RM_END_ID 0
|
||||
#define TWOPHASE_RM_LOCK_ID 1
|
||||
#define TWOPHASE_RM_INVAL_ID 2
|
||||
#define TWOPHASE_RM_NOTIFY_ID 3
|
||||
#define TWOPHASE_RM_PGSTAT_ID 4
|
||||
#define TWOPHASE_RM_MULTIXACT_ID 5
|
||||
#define TWOPHASE_RM_NOTIFY_ID 2
|
||||
#define TWOPHASE_RM_PGSTAT_ID 3
|
||||
#define TWOPHASE_RM_MULTIXACT_ID 4
|
||||
#define TWOPHASE_RM_MAX_ID TWOPHASE_RM_MULTIXACT_ID
|
||||
|
||||
extern const TwoPhaseCallback twophase_recover_callbacks[];
|
||||
extern const TwoPhaseCallback twophase_postcommit_callbacks[];
|
||||
extern const TwoPhaseCallback twophase_postabort_callbacks[];
|
||||
extern const TwoPhaseCallback twophase_standby_recover_callbacks[];
|
||||
|
||||
|
||||
extern void RegisterTwoPhaseRecord(TwoPhaseRmgrId rmid, uint16 info,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/xact.h,v 1.98 2009/06/11 14:49:09 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/xact.h,v 1.99 2009/12/19 01:32:42 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -84,19 +84,49 @@ typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid,
|
||||
#define XLOG_XACT_ABORT 0x20
|
||||
#define XLOG_XACT_COMMIT_PREPARED 0x30
|
||||
#define XLOG_XACT_ABORT_PREPARED 0x40
|
||||
#define XLOG_XACT_ASSIGNMENT 0x50
|
||||
|
||||
typedef struct xl_xact_assignment
|
||||
{
|
||||
TransactionId xtop; /* assigned XID's top-level XID */
|
||||
int nsubxacts; /* number of subtransaction XIDs */
|
||||
TransactionId xsub[1]; /* assigned subxids */
|
||||
} xl_xact_assignment;
|
||||
|
||||
#define MinSizeOfXactAssignment offsetof(xl_xact_assignment, xsub)
|
||||
|
||||
typedef struct xl_xact_commit
|
||||
{
|
||||
TimestampTz xact_time; /* time of commit */
|
||||
uint32 xinfo; /* info flags */
|
||||
int nrels; /* number of RelFileNodes */
|
||||
int nsubxacts; /* number of subtransaction XIDs */
|
||||
int nmsgs; /* number of shared inval msgs */
|
||||
/* Array of RelFileNode(s) to drop at commit */
|
||||
RelFileNode xnodes[1]; /* VARIABLE LENGTH ARRAY */
|
||||
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
|
||||
/* ARRAY OF SHARED INVALIDATION MESSAGES FOLLOWS */
|
||||
} xl_xact_commit;
|
||||
|
||||
#define MinSizeOfXactCommit offsetof(xl_xact_commit, xnodes)
|
||||
|
||||
/*
|
||||
* These flags are set in the xinfo fields of WAL commit records,
|
||||
* indicating a variety of additional actions that need to occur
|
||||
* when emulating transaction effects during recovery.
|
||||
* They are named XactCompletion... to differentiate them from
|
||||
* EOXact... routines which run at the end of the original
|
||||
* transaction completion.
|
||||
*/
|
||||
#define XACT_COMPLETION_UPDATE_RELCACHE_FILE 0x01
|
||||
#define XACT_COMPLETION_VACUUM_FULL 0x02
|
||||
#define XACT_COMPLETION_FORCE_SYNC_COMMIT 0x04
|
||||
|
||||
/* Access macros for above flags */
|
||||
#define XactCompletionRelcacheInitFileInval(xlrec) ((xlrec)->xinfo & XACT_COMPLETION_UPDATE_RELCACHE_FILE)
|
||||
#define XactCompletionVacuumFull(xlrec) ((xlrec)->xinfo & XACT_COMPLETION_VACUUM_FULL)
|
||||
#define XactCompletionForceSyncCommit(xlrec) ((xlrec)->xinfo & XACT_COMPLETION_FORCE_SYNC_COMMIT)
|
||||
|
||||
typedef struct xl_xact_abort
|
||||
{
|
||||
TimestampTz xact_time; /* time of abort */
|
||||
@@ -106,6 +136,7 @@ typedef struct xl_xact_abort
|
||||
RelFileNode xnodes[1]; /* VARIABLE LENGTH ARRAY */
|
||||
/* ARRAY OF ABORTED SUBTRANSACTION XIDs FOLLOWS */
|
||||
} xl_xact_abort;
|
||||
/* Note the intentional lack of an invalidation message array c.f. commit */
|
||||
|
||||
#define MinSizeOfXactAbort offsetof(xl_xact_abort, xnodes)
|
||||
|
||||
@@ -181,7 +212,7 @@ extern void UnregisterXactCallback(XactCallback callback, void *arg);
|
||||
extern void RegisterSubXactCallback(SubXactCallback callback, void *arg);
|
||||
extern void UnregisterSubXactCallback(SubXactCallback callback, void *arg);
|
||||
|
||||
extern TransactionId RecordTransactionCommit(void);
|
||||
extern TransactionId RecordTransactionCommit(bool isVacuumFull);
|
||||
|
||||
extern int xactGetCommittedChildren(TransactionId **ptr);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.93 2009/06/26 20:29:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.94 2009/12/19 01:32:42 sriggs Exp $
|
||||
*/
|
||||
#ifndef XLOG_H
|
||||
#define XLOG_H
|
||||
@@ -133,7 +133,45 @@ typedef struct XLogRecData
|
||||
} XLogRecData;
|
||||
|
||||
extern TimeLineID ThisTimeLineID; /* current TLI */
|
||||
|
||||
/*
|
||||
* Prior to 8.4, all activity during recovery was carried out by Startup
|
||||
* process. This local variable continues to be used in many parts of the
|
||||
* code to indicate actions taken by RecoveryManagers. Other processes who
|
||||
* potentially perform work during recovery should check RecoveryInProgress()
|
||||
* see XLogCtl notes in xlog.c
|
||||
*/
|
||||
extern bool InRecovery;
|
||||
|
||||
/*
|
||||
* Like InRecovery, standbyState is only valid in the startup process.
|
||||
*
|
||||
* In DISABLED state, we're performing crash recovery or hot standby was
|
||||
* disabled in recovery.conf.
|
||||
*
|
||||
* In INITIALIZED state, we haven't yet received a RUNNING_XACTS or shutdown
|
||||
* checkpoint record to initialize our master transaction tracking system.
|
||||
*
|
||||
* When the transaction tracking is initialized, we enter the SNAPSHOT_PENDING
|
||||
* state. The tracked information might still be incomplete, so we can't allow
|
||||
* connections yet, but redo functions must update the in-memory state when
|
||||
* appropriate.
|
||||
*
|
||||
* In SNAPSHOT_READY mode, we have full knowledge of transactions that are
|
||||
* (or were) running in the master at the current WAL location. Snapshots
|
||||
* can be taken, and read-only queries can be run.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
STANDBY_DISABLED,
|
||||
STANDBY_INITIALIZED,
|
||||
STANDBY_SNAPSHOT_PENDING,
|
||||
STANDBY_SNAPSHOT_READY
|
||||
} HotStandbyState;
|
||||
extern HotStandbyState standbyState;
|
||||
|
||||
#define InHotStandby (standbyState >= STANDBY_SNAPSHOT_PENDING)
|
||||
|
||||
extern XLogRecPtr XactLastRecEnd;
|
||||
|
||||
/* these variables are GUC parameters related to XLOG */
|
||||
@@ -143,9 +181,12 @@ extern bool XLogArchiveMode;
|
||||
extern char *XLogArchiveCommand;
|
||||
extern int XLogArchiveTimeout;
|
||||
extern bool log_checkpoints;
|
||||
extern bool XLogRequestRecoveryConnections;
|
||||
extern int MaxStandbyDelay;
|
||||
|
||||
#define XLogArchivingActive() (XLogArchiveMode)
|
||||
#define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0')
|
||||
#define XLogStandbyInfoActive() (XLogRequestRecoveryConnections && XLogArchiveMode)
|
||||
|
||||
#ifdef WAL_DEBUG
|
||||
extern bool XLOG_DEBUG;
|
||||
@@ -203,6 +244,7 @@ extern void xlog_desc(StringInfo buf, uint8 xl_info, char *rec);
|
||||
|
||||
extern bool RecoveryInProgress(void);
|
||||
extern bool XLogInsertAllowed(void);
|
||||
extern TimestampTz GetLatestXLogTime(void);
|
||||
|
||||
extern void UpdateControlFile(void);
|
||||
extern Size XLOGShmemSize(void);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.25 2009/01/01 17:23:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.26 2009/12/19 01:32:42 sriggs Exp $
|
||||
*/
|
||||
#ifndef XLOG_INTERNAL_H
|
||||
#define XLOG_INTERNAL_H
|
||||
@@ -71,7 +71,7 @@ typedef struct XLogContRecord
|
||||
/*
|
||||
* Each page of XLOG file has a header like this:
|
||||
*/
|
||||
#define XLOG_PAGE_MAGIC 0xD063 /* can be used as WAL version indicator */
|
||||
#define XLOG_PAGE_MAGIC 0xD166 /* can be used as WAL version indicator */
|
||||
|
||||
typedef struct XLogPageHeaderData
|
||||
{
|
||||
@@ -255,5 +255,6 @@ extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_current_xlog_insert_location(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_xlogfile_name_offset(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_xlogfile_name(PG_FUNCTION_ARGS);
|
||||
extern Datum pg_is_in_recovery(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* XLOG_INTERNAL_H */
|
||||
|
||||
Reference in New Issue
Block a user