standby.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*-------------------------------------------------------------------------
  2. *
  3. * standby.h
  4. * Definitions for hot standby mode.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, 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. #include "storage/standbydefs.h"
  17. #include "storage/lock.h"
  18. #include "storage/procsignal.h"
  19. #include "storage/relfilenode.h"
  20. /* User-settable GUC parameters */
  21. extern int vacuum_defer_cleanup_age;
  22. extern int max_standby_archive_delay;
  23. extern int max_standby_streaming_delay;
  24. extern void InitRecoveryTransactionEnvironment(void);
  25. extern void ShutdownRecoveryTransactionEnvironment(void);
  26. extern void ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid,
  27. RelFileNode node);
  28. extern void ResolveRecoveryConflictWithTablespace(Oid tsid);
  29. extern void ResolveRecoveryConflictWithDatabase(Oid dbid);
  30. extern void ResolveRecoveryConflictWithLock(LOCKTAG locktag);
  31. extern void ResolveRecoveryConflictWithBufferPin(void);
  32. extern void CheckRecoveryConflictDeadlock(void);
  33. extern void StandbyDeadLockHandler(void);
  34. extern void StandbyTimeoutHandler(void);
  35. extern void StandbyLockTimeoutHandler(void);
  36. /*
  37. * Standby Rmgr (RM_STANDBY_ID)
  38. *
  39. * Standby recovery manager exists to perform actions that are required
  40. * to make hot standby work. That includes logging AccessExclusiveLocks taken
  41. * by transactions and running-xacts snapshots.
  42. */
  43. extern void StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid relOid);
  44. extern void StandbyReleaseLockTree(TransactionId xid,
  45. int nsubxids, TransactionId *subxids);
  46. extern void StandbyReleaseAllLocks(void);
  47. extern void StandbyReleaseOldLocks(int nxids, TransactionId *xids);
  48. #define MinSizeOfXactRunningXacts offsetof(xl_running_xacts, xids)
  49. /*
  50. * Declarations for GetRunningTransactionData(). Similar to Snapshots, but
  51. * not quite. This has nothing at all to do with visibility on this server,
  52. * so this is completely separate from snapmgr.c and snapmgr.h.
  53. * This data is important for creating the initial snapshot state on a
  54. * standby server. We need lots more information than a normal snapshot,
  55. * hence we use a specific data structure for our needs. This data
  56. * is written to WAL as a separate record immediately after each
  57. * checkpoint. That means that wherever we start a standby from we will
  58. * almost immediately see the data we need to begin executing queries.
  59. */
  60. typedef struct RunningTransactionsData
  61. {
  62. int xcnt; /* # of xact ids in xids[] */
  63. int subxcnt; /* # of subxact ids in xids[] */
  64. bool subxid_overflow; /* snapshot overflowed, subxids missing */
  65. TransactionId nextXid; /* copy of ShmemVariableCache->nextXid */
  66. TransactionId oldestRunningXid; /* *not* oldestXmin */
  67. TransactionId latestCompletedXid; /* so we can set xmax */
  68. TransactionId *xids; /* array of (sub)xids still running */
  69. } RunningTransactionsData;
  70. typedef RunningTransactionsData *RunningTransactions;
  71. extern void LogAccessExclusiveLock(Oid dbOid, Oid relOid);
  72. extern void LogAccessExclusiveLockPrepare(void);
  73. extern XLogRecPtr LogStandbySnapshot(void);
  74. extern void LogStandbyInvalidations(int nmsgs, SharedInvalidationMessage *msgs,
  75. bool relcacheInitFileInval);
  76. #endif /* STANDBY_H */