PostgreSQL启动过程中的那些事七:初始化共享内存和信号二:shmem中初始化xlog(三)

2014-11-24 00:59:50 · 作者: · 浏览: 49
ock: */

XLogCtlInsertInsert;

/* Protected byinfo_lck: */

XLogwrtRqstLogwrtRqst;

XLogwrtResultLogwrtResult;

uint32 ckptXidEpoch; /* nextXID & epoch of latest checkpoint */

TransactionIdckptXid;

XLogRecPtr asyncXactLSN; /*LSN of newest async commit/abort */

uint32 lastRemovedLog; /* latest removed/recycledXLOG segment */

uint32 lastRemovedSeg;

/* Protected byWALWriteLock: */

XLogCtlWrite Write;

/*

* These values do not change after startup,although the pointed-to pages

* and xlblocks values certainly do. Permission to read/write the pages

* and xlblocks values depends on WALInsertLockand WALWriteLock.

*/

char *pages; /* buffers forunwritten XLOG pages */

XLogRecPtr*xlblocks; /* 1st byte ptr-s +XLOG_BLCKSZ */

int XLogCacheBlck; /* highest allocated xlog buffer index */

TimeLineID ThisTimeLineID;

TimeLineID RecoveryTargetTLI;

/*

* archiveCleanupCommand is read fromrecovery.conf but needs to be in

* shared memory so that the bgwriter processcan access it.

*/

char archiveCleanupCommand[MAXPGPATH];

/*

* SharedRecoveryInProgress indicates if we'restill in crash or archive

* recovery. Protected by info_lck.

*/

bool SharedRecoveryInProgress;

/*

* SharedHotStandbyActive indicates if we'restill in crash or archive

* recovery. Protected by info_lck.

*/

bool SharedHotStandbyActive;

/*

* recoveryWakeupLatch is used to wake up thestartup process to continue

* WAL replay, if it is waiting for WAL toarrive or failover trigger file

* to appear.

*/

Latch recoveryWakeupLatch;

/*

* During recovery, we keep a copy of thelatest checkpoint record here.

* Used by the background writer when it wantsto create a restartpoint.

*

* Protected by info_lck.

*/

XLogRecPtr lastCheckPointRecPtr;

CheckPoint lastCheckPoint;

/* end+1 of the lastrecord replayed (or being replayed) */

XLogRecPtr replayEndRecPtr;

/* end+1 of the lastrecord replayed */

XLogRecPtr recoveryLastRecPtr;

/* timestamp of lastCOMMIT/ABORT record replayed (or being replayed) */

TimestampTzrecoveryLastXTime;

/* Are we requestedto pause recovery */

bool recoveryPause;

slock_t info_lck; /*locks shared variables shown above */

} XLogCtlData;

/*

* Shared state datafor XLogInsert.

*/

typedef struct XLogCtlInsert

{

XLogwrtResultLogwrtResult; /* a recent value of LogwrtResult */

XLogRecPtr PrevRecord; /*start of previously-inserted record */

int curridx; /* current block index in cache */

XLogPageHeadercurrpage; /* points to header of blockin cache */

char *currpos; /* currentinsertion point in cache */

XLogRecPtr RedoRecPtr; /*current redo point for insertions */

bool forcePageWrites; /* forcing full-page writes for PITR */

/*

* exclusiveBackup is true if a backup startedwith pg_start_backup() is

* in progress, and nonExclusiveBackups is acounter indicating the number

* of streaming base backups currently inprogress. forcePageWrites is set

* to true when either of these is non-zero.lastBackupStart is the latest

* ch