typedefstruct XidCacheStatus
{ /* number of cached subxids, never more than PGPROC_MAX_CACHED_SUBXIDS */
uint8 count; /* has PGPROC->subxids overflowed */ bool overflowed;
} XidCacheStatus;
/* *FlagsforPGPROC->statusFlagsandPROC_HDR->statusFlags[]
*/ #define PROC_IS_AUTOVACUUM 0x01 /* is it an autovac worker? */ #define PROC_IN_VACUUM 0x02 /* currently running lazy vacuum */ #define PROC_IN_SAFE_IC 0x04 /* currently running CREATE INDEX *CONCURRENTLYorREINDEX *CONCURRENTLYonnon-expressional,
* non-partial index */ #define PROC_VACUUM_FOR_WRAPAROUND 0x08 /* set by autovac only */ #define PROC_IN_LOGICAL_DECODING 0x10 /* currently doing logical
* decoding outside xact */ #define PROC_AFFECTS_ALL_HORIZONS 0x20 /* this proc's xmin must be *includedinvacuumhorizons
* in all databases */
/* *EachbackendhasaPGPROCstructinsharedmemory.Thereisalsoalistof *currently-unusedPGPROCstructsthatwillbereallocatedtonewbackends. * *links:listlinkforanylistthePGPROCisin.Whenwaitingforalock, *thePGPROCislinkedintothatlock'swaitProcsqueue.ArecycledPGPROC *islinkedintoProcGlobal'sfreeProcslist. * *Note:twophase.calsosetsupadummyPGPROCstructforeachcurrently *preparedtransaction.ThesePGPROCsappearintheProcArraydatastructure *sothatthepreparedtransactionsappeartobestillrunningandare *correctlyshownasholdinglocks.ApreparedtransactionPGPROCcanbe *distinguishedfromarealoneatneedbythefactthatithaspid==0. *Thesemaphoreandlock-activityfieldsinaprepared-xactPGPROCareunused, *butitsmyProcLocks[]listsarevalid. * *Weallowmanyfieldsofthisstructtobeaccessedwithoutlocks,suchas *delayChkptFlagsandisRegularBackend.However,keepinmindthatwriting *mirroredones(seebelow)requiresholdingProcArrayLockorXidGenLockin *atleastsharedmode,sothatpgxactoffdoesnotchangeconcurrently. * *Mirroredfields: * *SomefieldsinPGPROC(see"mirroredin..."comment)aremirroredintoan *elementofmoredenselypackedProcGlobalarrays.Thesearraysareindexed *byPGPROC->pgxactoff.Bothcopiesneedtobemaintainedcoherently. * *NB:Thepgxactoffindexedvaluecan*never*beaccessedwithoutholding *locks. * *SeePROC_HDRfordetails.
*/ struct PGPROC
{
dlist_node links; /* list link if process is in a list */
dlist_head *procgloballist; /* procglobal list that owns this PGPROC */
PGSemaphore sem; /* ONE semaphore to sleep on */
ProcWaitStatus waitStatus;
Latch procLatch; /* generic latch for process */
TransactionId xid; /* id of top-level transaction currently being *executedbythisproc,ifrunningandXID *isassigned;elseInvalidTransactionId.
* mirrored in ProcGlobal->xids[pgxactoff] */
TransactionId xmin; /* minimal running XID as it was when we were *startingourxact,excludingLAZYVACUUM: *vacuummustnotremovetuplesdeletedby
* xid >= xmin ! */
int pid; /* Backend's process ID; 0 if prepared xact */
int pgxactoff; /* offset into various ProcGlobal->arrays with
* data mirrored from this PGPROC */
/* *Currentlyrunningtop-leveltransaction'svirtualxid.Togetherthese *formaVirtualTransactionId,butwedon'tusethatstructbecausethis *isnotatomicallyassignableaswhole,andwewanttoenforcecodeto *considerbothpartsseparately.SeecommentsatVirtualTransactionId.
*/ struct
{
ProcNumber procNumber; /* For regular backends, equal to *GetNumberFromPGProc(proc).Forprepared *xacts,IDoftheoriginalbackendthat *processedthetransaction.Forunused
* PGPROC entries, INVALID_PROC_NUMBER. */
LocalTransactionId lxid; /* local id of top-level transaction *currently*beingexecutedbythis *proc,ifrunning;else
* InvalidLocalTransactionId */
} vxid;
/* These fields are zero while a backend is still starting up: */
Oid databaseId; /* OID of database this backend is using */
Oid roleId; /* OID of role using this backend */
Oid tempNamespaceId; /* OID of temp schema this backend is
* using */
bool isRegularBackend; /* true if it's a regular backend. */
/* Info about LWLock the process is currently waiting for, if any. */
uint8 lwWaiting; /* see LWLockWaitState */
uint8 lwWaitMode; /* lwlock mode being waited for */
proclist_node lwWaitLink; /* position in LW lock wait list */
/* Support for condition variables. */
proclist_node cvWaitLink; /* position in CV wait list */
/* Info about lock the process is currently waiting for, if any. */ /* waitLock and waitProcLock are NULL if not currently waiting. */
LOCK *waitLock; /* Lock object we're sleeping on ... */
PROCLOCK *waitProcLock; /* Per-holder info for awaited lock */
LOCKMODE waitLockMode; /* type of lock we're waiting for */
LOCKMASK heldLocks; /* bitmask for lock types already held on this
* lock object by this backend */
pg_atomic_uint64 waitStart; /* time at which wait for lock acquisition
* started */
int delayChkptFlags; /* for DELAY_CHKPT_* flags */
uint8 statusFlags; /* this backend's status flags, see PROC_* *above.mirroredin
* ProcGlobal->statusFlags[pgxactoff] */
/* *Infotoallowustowaitforsynchronousreplication,ifneeded. *waitLSNisInvalidXLogRecPtrifnotwaiting;setonlybyuserbackend. *syncRepStatemustnotbetouchedexceptbyowningprocessorWALSender. *syncRepLinksusedonlywhileholdingSyncRepLock.
*/
XLogRecPtr waitLSN; /* waiting for this LSN or higher */ int syncRepState; /* wait state for sync rep */
dlist_node syncRepLinks; /* list link if process is in syncrep queue */
XidCacheStatus subxidStatus; /* mirrored with
* ProcGlobal->subxidStates[i] */ struct XidCache subxids; /* cache for subtransaction XIDs */
/* Support for group XID clearing. */ /* true, if member of ProcArray group waiting for XID clear */ bool procArrayGroupMember; /* next ProcArray group member waiting for XID clear */
pg_atomic_uint32 procArrayGroupNext;
uint32 wait_event_info; /* proc's wait information */
/* Support for group transaction status update. */ bool clogGroupMember; /* true, if member of clog group */
pg_atomic_uint32 clogGroupNext; /* next clog group member */
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
/* Lock manager data, recording fast-path locks taken by this backend. */
LWLock fpInfoLock; /* protects per-backend fast-path state */
uint64 *fpLockBits; /* lock modes held for each fast-path slot */
Oid *fpRelId; /* slots for rel oids */ bool fpVXIDLock; /* are we holding a fast-path VXID lock? */
LocalTransactionId fpLocalTransactionId; /* lxid for fast-path VXID
* lock */
/* *Supportforlockgroups.UseLockHashPartitionLockByProconthegroup *leadertogettheLWLockprotectingthesefields.
*/
PGPROC *lockGroupLeader; /* lock group leader, if I'm a member */
dlist_head lockGroupMembers; /* list of members, if I'm a leader */
dlist_node lockGroupLink; /* my member link, if I'm a member */
};
/* NOTE: "typedef struct PGPROC PGPROC" appears in storage/lock.h. */
/* Length of allProcs array */
uint32 allProcCount; /* Head of list of free PGPROC structures */
dlist_head freeProcs; /* Head of list of autovacuum & special worker free PGPROC structures */
dlist_head autovacFreeProcs; /* Head of list of bgworker free PGPROC structures */
dlist_head bgworkerFreeProcs; /* Head of list of walsender free PGPROC structures */
dlist_head walsenderFreeProcs; /* First pgproc waiting for group XID clear */
pg_atomic_uint32 procArrayGroupFirst; /* First pgproc waiting for group transaction status update */
pg_atomic_uint32 clogGroupFirst;
/* Current shared estimate of appropriate spins_per_delay value */ int spins_per_delay; /* Buffer id of the buffer that Startup process waits for pin on, or -1 */ int startupBufferPinWaitBufId;
} PROC_HDR;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.