PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
standbydefs.h File Reference
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/lockdefs.h"
#include "storage/sinval.h"
Include dependency graph for standbydefs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_standby_locks
 
struct  xl_running_xacts
 
struct  xl_invalidations
 

Macros

#define XLOG_STANDBY_LOCK   0x00
 
#define XLOG_RUNNING_XACTS   0x10
 
#define XLOG_INVALIDATIONS   0x20
 
#define MinSizeOfInvalidations   offsetof(xl_invalidations, msgs)
 

Typedefs

typedef struct xl_standby_locks xl_standby_locks
 
typedef struct xl_running_xacts xl_running_xacts
 
typedef struct xl_invalidations xl_invalidations
 

Functions

void standby_redo (XLogReaderState *record)
 
void standby_desc (StringInfo buf, XLogReaderState *record)
 
const char * standby_identify (uint8 info)
 
void standby_desc_invalidations (StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)
 

Macro Definition Documentation

#define MinSizeOfInvalidations   offsetof(xl_invalidations, msgs)

Definition at line 72 of file standbydefs.h.

Referenced by LogStandbyInvalidations().

#define XLOG_INVALIDATIONS   0x20
#define XLOG_RUNNING_XACTS   0x10
#define XLOG_STANDBY_LOCK   0x00

Typedef Documentation

Function Documentation

void standby_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 40 of file standbydesc.c.

References appendStringInfo(), xl_invalidations::dbId, xl_standby_lock::dbOid, i, xl_standby_locks::locks, xl_invalidations::msgs, xl_standby_locks::nlocks, xl_invalidations::nmsgs, xl_invalidations::relcacheInitFileInval, xl_standby_lock::relOid, standby_desc_invalidations(), standby_desc_running_xacts(), xl_invalidations::tsId, xl_standby_lock::xid, XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

41 {
42  char *rec = XLogRecGetData(record);
43  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
44 
45  if (info == XLOG_STANDBY_LOCK)
46  {
47  xl_standby_locks *xlrec = (xl_standby_locks *) rec;
48  int i;
49 
50  for (i = 0; i < xlrec->nlocks; i++)
51  appendStringInfo(buf, "xid %u db %u rel %u ",
52  xlrec->locks[i].xid, xlrec->locks[i].dbOid,
53  xlrec->locks[i].relOid);
54  }
55  else if (info == XLOG_RUNNING_XACTS)
56  {
57  xl_running_xacts *xlrec = (xl_running_xacts *) rec;
58 
59  standby_desc_running_xacts(buf, xlrec);
60  }
61  else if (info == XLOG_INVALIDATIONS)
62  {
63  xl_invalidations *xlrec = (xl_invalidations *) rec;
64 
65  standby_desc_invalidations(buf, xlrec->nmsgs, xlrec->msgs,
66  xlrec->dbId, xlrec->tsId,
67  xlrec->relcacheInitFileInval);
68  }
69 }
void standby_desc_invalidations(StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)
Definition: standbydesc.c:98
#define XLOG_INVALIDATIONS
Definition: standbydefs.h:36
unsigned char uint8
Definition: c.h:266
#define XLOG_STANDBY_LOCK
Definition: standbydefs.h:34
#define XLogRecGetData(decoder)
Definition: xlogreader.h:218
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:110
bool relcacheInitFileInval
Definition: standbydefs.h:67
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:214
TransactionId xid
Definition: lockdefs.h:51
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:69
xl_standby_lock locks[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:41
static void standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
Definition: standbydesc.c:20
int i
#define XLOG_RUNNING_XACTS
Definition: standbydefs.h:35
void standby_desc_invalidations ( StringInfo  buf,
int  nmsgs,
SharedInvalidationMessage msgs,
Oid  dbId,
Oid  tsId,
bool  relcacheInitFileInval 
)

Definition at line 98 of file standbydesc.c.

References appendStringInfo(), appendStringInfoString(), SharedInvalidationMessage::cat, SharedInvalCatalogMsg::catId, SharedInvalRelmapMsg::dbId, i, SharedInvalidationMessage::id, SharedInvalidationMessage::rc, SharedInvalRelcacheMsg::relId, SharedInvalSnapshotMsg::relId, SharedInvalidationMessage::rm, SHAREDINVALCATALOG_ID, SHAREDINVALRELCACHE_ID, SHAREDINVALRELMAP_ID, SHAREDINVALSMGR_ID, SHAREDINVALSNAPSHOT_ID, and SharedInvalidationMessage::sn.

Referenced by standby_desc(), and xact_desc_commit().

102 {
103  int i;
104 
105  if (relcacheInitFileInval)
106  appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
107  dbId, tsId);
108 
109  appendStringInfoString(buf, "; inval msgs:");
110  for (i = 0; i < nmsgs; i++)
111  {
112  SharedInvalidationMessage *msg = &msgs[i];
113 
114  if (msg->id >= 0)
115  appendStringInfo(buf, " catcache %d", msg->id);
116  else if (msg->id == SHAREDINVALCATALOG_ID)
117  appendStringInfo(buf, " catalog %u", msg->cat.catId);
118  else if (msg->id == SHAREDINVALRELCACHE_ID)
119  appendStringInfo(buf, " relcache %u", msg->rc.relId);
120  /* not expected, but print something anyway */
121  else if (msg->id == SHAREDINVALSMGR_ID)
122  appendStringInfoString(buf, " smgr");
123  /* not expected, but print something anyway */
124  else if (msg->id == SHAREDINVALRELMAP_ID)
125  appendStringInfo(buf, " relmap db %u", msg->rm.dbId);
126  else if (msg->id == SHAREDINVALSNAPSHOT_ID)
127  appendStringInfo(buf, " snapshot %u", msg->sn.relId);
128  else
129  appendStringInfo(buf, " unrecognized id %d", msg->id);
130  }
131 }
SharedInvalSnapshotMsg sn
Definition: sinval.h:121
SharedInvalRelcacheMsg rc
Definition: sinval.h:118
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:110
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:189
#define SHAREDINVALRELCACHE_ID
Definition: sinval.h:76
SharedInvalRelmapMsg rm
Definition: sinval.h:120
#define SHAREDINVALRELMAP_ID
Definition: sinval.h:96
SharedInvalCatalogMsg cat
Definition: sinval.h:117
#define SHAREDINVALSNAPSHOT_ID
Definition: sinval.h:104
#define SHAREDINVALCATALOG_ID
Definition: sinval.h:67
int i
#define SHAREDINVALSMGR_ID
Definition: sinval.h:85
const char* standby_identify ( uint8  info)

Definition at line 72 of file standbydesc.c.

References NULL, XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, and XLR_INFO_MASK.

73 {
74  const char *id = NULL;
75 
76  switch (info & ~XLR_INFO_MASK)
77  {
78  case XLOG_STANDBY_LOCK:
79  id = "LOCK";
80  break;
81  case XLOG_RUNNING_XACTS:
82  id = "RUNNING_XACTS";
83  break;
84  case XLOG_INVALIDATIONS:
85  id = "INVALIDATIONS";
86  break;
87  }
88 
89  return id;
90 }
#define XLOG_INVALIDATIONS
Definition: standbydefs.h:36
#define XLOG_STANDBY_LOCK
Definition: standbydefs.h:34
#define NULL
Definition: c.h:229
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_RUNNING_XACTS
Definition: standbydefs.h:35
void standby_redo ( XLogReaderState record)

Definition at line 792 of file standby.c.

References Assert, xl_invalidations::dbId, xl_standby_lock::dbOid, elog, i, xl_running_xacts::latestCompletedXid, RunningTransactionsData::latestCompletedXid, xl_standby_locks::locks, xl_invalidations::msgs, xl_running_xacts::nextXid, RunningTransactionsData::nextXid, xl_standby_locks::nlocks, xl_invalidations::nmsgs, xl_running_xacts::oldestRunningXid, RunningTransactionsData::oldestRunningXid, PANIC, ProcArrayApplyRecoveryInfo(), ProcessCommittedInvalidationMessages(), xl_invalidations::relcacheInitFileInval, xl_standby_lock::relOid, STANDBY_DISABLED, StandbyAcquireAccessExclusiveLock(), standbyState, xl_running_xacts::subxcnt, RunningTransactionsData::subxcnt, xl_running_xacts::subxid_overflow, RunningTransactionsData::subxid_overflow, xl_invalidations::tsId, xl_running_xacts::xcnt, RunningTransactionsData::xcnt, xl_standby_lock::xid, xl_running_xacts::xids, RunningTransactionsData::xids, XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, XLogRecGetData, XLogRecGetInfo, XLogRecHasAnyBlockRefs, and XLR_INFO_MASK.

793 {
794  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
795 
796  /* Backup blocks are not used in standby records */
797  Assert(!XLogRecHasAnyBlockRefs(record));
798 
799  /* Do nothing if we're not in hot standby mode */
801  return;
802 
803  if (info == XLOG_STANDBY_LOCK)
804  {
805  xl_standby_locks *xlrec = (xl_standby_locks *) XLogRecGetData(record);
806  int i;
807 
808  for (i = 0; i < xlrec->nlocks; i++)
810  xlrec->locks[i].dbOid,
811  xlrec->locks[i].relOid);
812  }
813  else if (info == XLOG_RUNNING_XACTS)
814  {
815  xl_running_xacts *xlrec = (xl_running_xacts *) XLogRecGetData(record);
816  RunningTransactionsData running;
817 
818  running.xcnt = xlrec->xcnt;
819  running.subxcnt = xlrec->subxcnt;
820  running.subxid_overflow = xlrec->subxid_overflow;
821  running.nextXid = xlrec->nextXid;
822  running.latestCompletedXid = xlrec->latestCompletedXid;
823  running.oldestRunningXid = xlrec->oldestRunningXid;
824  running.xids = xlrec->xids;
825 
826  ProcArrayApplyRecoveryInfo(&running);
827  }
828  else if (info == XLOG_INVALIDATIONS)
829  {
830  xl_invalidations *xlrec = (xl_invalidations *) XLogRecGetData(record);
831 
833  xlrec->nmsgs,
834  xlrec->relcacheInitFileInval,
835  xlrec->dbId,
836  xlrec->tsId);
837  }
838  else
839  elog(PANIC, "standby_redo: unknown op code %u", info);
840 }
void ProcArrayApplyRecoveryInfo(RunningTransactions running)
Definition: procarray.c:664
TransactionId oldestRunningXid
Definition: standby.h:76
#define XLOG_INVALIDATIONS
Definition: standbydefs.h:36
unsigned char uint8
Definition: c.h:266
#define XLOG_STANDBY_LOCK
Definition: standbydefs.h:34
TransactionId * xids
Definition: standby.h:79
#define PANIC
Definition: elog.h:53
TransactionId latestCompletedXid
Definition: standby.h:77
TransactionId xids[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:56
#define XLogRecGetData(decoder)
Definition: xlogreader.h:218
TransactionId latestCompletedXid
Definition: standbydefs.h:54
bool relcacheInitFileInval
Definition: standbydefs.h:67
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:214
TransactionId xid
Definition: lockdefs.h:51
void ProcessCommittedInvalidationMessages(SharedInvalidationMessage *msgs, int nmsgs, bool RelcacheInitFileInval, Oid dbid, Oid tsid)
Definition: inval.c:865
#define Assert(condition)
Definition: c.h:675
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:69
TransactionId nextXid
Definition: standbydefs.h:52
xl_standby_lock locks[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:41
TransactionId nextXid
Definition: standby.h:75
void StandbyAcquireAccessExclusiveLock(TransactionId xid, Oid dbOid, Oid relOid)
Definition: standby.c:602
int i
TransactionId oldestRunningXid
Definition: standbydefs.h:53
#define XLOG_RUNNING_XACTS
Definition: standbydefs.h:35
#define XLogRecHasAnyBlockRefs(decoder)
Definition: xlogreader.h:220
#define elog
Definition: elog.h:219
HotStandbyState standbyState
Definition: xlog.c:195