postgreSQL 的 lightweight lock

前端之家收集整理的这篇文章主要介绍了postgreSQL 的 lightweight lock前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

LWLocks are normally used to protect not-very-long sections of computation

typedef struct LWLock
{
slock_t mutex; /* Protects LWLock and queue of PGPROCs */
bool releaSEOK; /* T if ok to release waiters */
char exclusive; /* # of exclusive holders (0 or 1) */
int shared; /* # of shared holders (0..MaxBackends) */
PGPROC *head; /* head of list of waiting PGPROCs */
PGPROC *tail; /* tail of list of waiting PGPROCs */
/* tail is undefined when head is NULL */
} LWLock;

LWLock既可以封锁exclusive,又可以封锁shared,而且一个锁可以存在一个等待队列,队列中两种锁都可以有

lw lock 有一部分是固定的,在 lwlock.h 中

typedef enum LWLockId
{
BufFreelistLock,
ShmemIndexLock,
OidGenLock,
XidGenLock,
ProcArrayLock,
SInvalReadLock,
SInvalWriteLock,
WALInsertLock,
WALWriteLock,
ControlFileLock,
CheckpointLock,
CLogControlLock,
SubtransControlLock,
MultiXactGenLock,
MultiXactOffsetControlLock,
MultiXactMemberControlLock,
RelCacheInitLock,
BgWriterCommLock,
TwoPhaseStateLock,
TablespaceCreateLock,
BtreeVacuumLock,
AddinShmemInitLock,
AutovacuumLock,
AutovacuumScheduleLock,
SyncScanLock,
/* Individual lock IDs end here */
FirstBufMappingLock,
FirstLockMgrLock = FirstBufMappingLock + NUM_BUFFER_PARTITIONS,

/* must be last except for MaxDynamicLWLock: */
NumFixedLWLocks = FirstLockMgrLock + NUM_LOCK_PARTITIONS,

MaxDynamicLWLock = 1000000000
} LWLockId;

余下的是可被分配的,总共有8317个,这是多个计算出来的

猜你在找的Postgre SQL相关文章