PostgreSQL Source Code  git master
standby.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * standby.h
4  * Definitions for hot standby mode.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/storage/standby.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef STANDBY_H
15 #define STANDBY_H
16 
17 #include "storage/standbydefs.h"
18 #include "storage/lock.h"
19 #include "storage/procsignal.h"
20 #include "storage/relfilenode.h"
21 
22 /* User-settable GUC parameters */
23 extern int vacuum_defer_cleanup_age;
24 extern int max_standby_archive_delay;
26 
27 extern void InitRecoveryTransactionEnvironment(void);
29 
30 extern void ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid,
31  RelFileNode node);
34 
35 extern void ResolveRecoveryConflictWithLock(LOCKTAG locktag);
36 extern void ResolveRecoveryConflictWithBufferPin(void);
37 extern void CheckRecoveryConflictDeadlock(void);
38 extern void StandbyDeadLockHandler(void);
39 extern void StandbyTimeoutHandler(void);
40 extern void StandbyLockTimeoutHandler(void);
41 
42 /*
43  * Standby Rmgr (RM_STANDBY_ID)
44  *
45  * Standby recovery manager exists to perform actions that are required
46  * to make hot standby work. That includes logging AccessExclusiveLocks taken
47  * by transactions and running-xacts snapshots.
48  */
49 extern void StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid relOid);
51  int nsubxids, TransactionId *subxids);
52 extern void StandbyReleaseAllLocks(void);
53 extern void StandbyReleaseOldLocks(int nxids, TransactionId *xids);
54 
55 #define MinSizeOfXactRunningXacts offsetof(xl_running_xacts, xids)
56 
57 
58 /*
59  * Declarations for GetRunningTransactionData(). Similar to Snapshots, but
60  * not quite. This has nothing at all to do with visibility on this server,
61  * so this is completely separate from snapmgr.c and snapmgr.h.
62  * This data is important for creating the initial snapshot state on a
63  * standby server. We need lots more information than a normal snapshot,
64  * hence we use a specific data structure for our needs. This data
65  * is written to WAL as a separate record immediately after each
66  * checkpoint. That means that wherever we start a standby from we will
67  * almost immediately see the data we need to begin executing queries.
68  */
69 
71 {
72  int xcnt; /* # of xact ids in xids[] */
73  int subxcnt; /* # of subxact ids in xids[] */
74  bool subxid_overflow; /* snapshot overflowed, subxids missing */
75  TransactionId nextXid; /* copy of ShmemVariableCache->nextXid */
76  TransactionId oldestRunningXid; /* *not* oldestXmin */
77  TransactionId latestCompletedXid; /* so we can set xmax */
78 
79  TransactionId *xids; /* array of (sub)xids still running */
81 
83 
84 extern void LogAccessExclusiveLock(Oid dbOid, Oid relOid);
85 extern void LogAccessExclusiveLockPrepare(void);
86 
87 extern XLogRecPtr LogStandbySnapshot(void);
88 extern void LogStandbyInvalidations(int nmsgs, SharedInvalidationMessage *msgs,
89  bool relcacheInitFileInval);
90 
91 #endif /* STANDBY_H */
TransactionId oldestRunningXid
Definition: standby.h:76
void ResolveRecoveryConflictWithDatabase(Oid dbid)
Definition: standby.c:319
uint32 TransactionId
Definition: c.h:445
int vacuum_defer_cleanup_age
Definition: standby.c:37
void ResolveRecoveryConflictWithBufferPin(void)
Definition: standby.c:434
RunningTransactionsData * RunningTransactions
Definition: standby.h:82
Definition: lock.h:178
TransactionId * xids
Definition: standby.h:79
unsigned int Oid
Definition: postgres_ext.h:31
void ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileNode node)
Definition: standby.c:267
int max_standby_archive_delay
Definition: standby.c:38
void InitRecoveryTransactionEnvironment(void)
Definition: standby.c:63
TransactionId latestCompletedXid
Definition: standby.h:77
void LogAccessExclusiveLock(Oid dbOid, Oid relOid)
Definition: standby.c:1047
struct RunningTransactionsData RunningTransactionsData
int max_standby_streaming_delay
Definition: standby.c:39
XLogRecPtr LogStandbySnapshot(void)
Definition: standby.c:909
void StandbyReleaseAllLocks(void)
Definition: standby.c:690
void LogAccessExclusiveLockPrepare(void)
Definition: standby.c:1069
void StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid relOid)
Definition: standby.c:602
void StandbyReleaseLockTree(TransactionId xid, int nsubxids, TransactionId *subxids)
Definition: standby.c:676
void StandbyReleaseOldLocks(int nxids, TransactionId *xids)
Definition: standby.c:725
void CheckRecoveryConflictDeadlock(void)
Definition: standby.c:515
void ResolveRecoveryConflictWithLock(LOCKTAG locktag)
Definition: standby.c:362
void LogStandbyInvalidations(int nmsgs, SharedInvalidationMessage *msgs, bool relcacheInitFileInval)
Definition: standby.c:1091
void StandbyLockTimeoutHandler(void)
Definition: standby.c:571
void StandbyDeadLockHandler(void)
Definition: standby.c:547
void ShutdownRecoveryTransactionEnvironment(void)
Definition: standby.c:102
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void ResolveRecoveryConflictWithTablespace(Oid tsid)
Definition: standby.c:291
TransactionId nextXid
Definition: standby.h:75
void StandbyTimeoutHandler(void)
Definition: standby.c:558