Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
standby.h100 linesDownload Raw Back to storage
1/*-------------------------------------------------------------------------2 *3 * standby.h4 *	  Definitions for hot standby mode.5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/storage/standby.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef STANDBY_H15#define STANDBY_H16 17#include "datatype/timestamp.h"18#include "storage/lock.h"19#include "storage/procsignal.h"20#include "storage/relfilelocator.h"21#include "storage/standbydefs.h"22 23/* User-settable GUC parameters */24extern PGDLLIMPORT int max_standby_archive_delay;25extern PGDLLIMPORT int max_standby_streaming_delay;26extern PGDLLIMPORT bool log_recovery_conflict_waits;27 28extern void InitRecoveryTransactionEnvironment(void);29extern void ShutdownRecoveryTransactionEnvironment(void);30 31extern void ResolveRecoveryConflictWithSnapshot(TransactionId snapshotConflictHorizon,32												bool isCatalogRel,33												RelFileLocator locator);34extern void ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId snapshotConflictHorizon,35													   bool isCatalogRel,36													   RelFileLocator locator);37extern void ResolveRecoveryConflictWithTablespace(Oid tsid);38extern void ResolveRecoveryConflictWithDatabase(Oid dbid);39 40extern void ResolveRecoveryConflictWithLock(LOCKTAG locktag, bool logging_conflict);41extern void ResolveRecoveryConflictWithBufferPin(void);42extern void CheckRecoveryConflictDeadlock(void);43extern void StandbyDeadLockHandler(void);44extern void StandbyTimeoutHandler(void);45extern void StandbyLockTimeoutHandler(void);46extern void LogRecoveryConflict(ProcSignalReason reason, TimestampTz wait_start,47								TimestampTz now, VirtualTransactionId *wait_list,48								bool still_waiting);49 50/*51 * Standby Rmgr (RM_STANDBY_ID)52 *53 * Standby recovery manager exists to perform actions that are required54 * to make hot standby work. That includes logging AccessExclusiveLocks taken55 * by transactions and running-xacts snapshots.56 */57extern void StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid relOid);58extern void StandbyReleaseLockTree(TransactionId xid,59								   int nsubxids, TransactionId *subxids);60extern void StandbyReleaseAllLocks(void);61extern void StandbyReleaseOldLocks(TransactionId oldxid);62 63#define MinSizeOfXactRunningXacts offsetof(xl_running_xacts, xids)64 65 66/*67 * Declarations for GetRunningTransactionData(). Similar to Snapshots, but68 * not quite. This has nothing at all to do with visibility on this server,69 * so this is completely separate from snapmgr.c and snapmgr.h.70 * This data is important for creating the initial snapshot state on a71 * standby server. We need lots more information than a normal snapshot,72 * hence we use a specific data structure for our needs. This data73 * is written to WAL as a separate record immediately after each74 * checkpoint. That means that wherever we start a standby from we will75 * almost immediately see the data we need to begin executing queries.76 */77 78typedef struct RunningTransactionsData79{80	int			xcnt;			/* # of xact ids in xids[] */81	int			subxcnt;		/* # of subxact ids in xids[] */82	bool		subxid_overflow;	/* snapshot overflowed, subxids missing */83	TransactionId nextXid;		/* xid from ShmemVariableCache->nextXid */84	TransactionId oldestRunningXid; /* *not* oldestXmin */85	TransactionId latestCompletedXid;	/* so we can set xmax */86 87	TransactionId *xids;		/* array of (sub)xids still running */88} RunningTransactionsData;89 90typedef RunningTransactionsData *RunningTransactions;91 92extern void LogAccessExclusiveLock(Oid dbOid, Oid relOid);93extern void LogAccessExclusiveLockPrepare(void);94 95extern XLogRecPtr LogStandbySnapshot(void);96extern void LogStandbyInvalidations(int nmsgs, SharedInvalidationMessage *msgs,97									bool relcacheInitFileInval);98 99#endif							/* STANDBY_H */100 
codekingpro/portable-devtools · Team Ai