diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/storage/lock.h | 13 | ||||
-rw-r--r-- | src/include/storage/proc.h | 12 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index 43eca860b81..6b4e3655f87 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -346,6 +346,7 @@ typedef struct PROCLOCK PROCLOCKTAG tag; /* unique identifier of proclock object */ /* data */ + PGPROC *groupLeader; /* group leader, or NULL if no lock group */ LOCKMASK holdMask; /* bitmask for lock types currently held */ LOCKMASK releaseMask; /* bitmask for lock types to be released */ SHM_QUEUE lockLink; /* list link in LOCK's list of proclocks */ @@ -457,7 +458,6 @@ typedef enum * worker */ } DeadLockState; - /* * The lockmgr's shared hash tables are partitioned to reduce contention. * To determine which partition a given locktag belongs to, compute the tag's @@ -473,6 +473,17 @@ typedef enum (&MainLWLockArray[LOCK_MANAGER_LWLOCK_OFFSET + (i)].lock) /* + * The deadlock detector needs to be able to access lockGroupLeader and + * related fields in the PGPROC, so we arrange for those fields to be protected + * by one of the lock hash partition locks. Since the deadlock detector + * acquires all such locks anyway, this makes it safe for it to access these + * fields without doing anything extra. To avoid contention as much as + * possible, we map different PGPROCs to different partition locks. + */ +#define LockHashPartitionLockByProc(p) \ + LockHashPartitionLock((p)->pgprocno) + +/* * function prototypes */ extern void InitLocks(void); diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 3441288dd06..66ab255f4c6 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -155,6 +155,15 @@ struct PGPROC bool fpVXIDLock; /* are we holding a fast-path VXID lock? */ LocalTransactionId fpLocalTransactionId; /* lxid for fast-path VXID * lock */ + + /* + * Support for lock groups. Use LockHashPartitionLockByProc to get the + * LWLock protecting these fields. + */ + int lockGroupLeaderIdentifier; /* MyProcPid, if I'm a leader */ + PGPROC *lockGroupLeader; /* lock group leader, if I'm a follower */ + 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. */ @@ -272,4 +281,7 @@ extern void LockErrorCleanup(void); extern void ProcWaitForSignal(void); extern void ProcSendSignal(int pid); +extern void BecomeLockGroupLeader(void); +extern bool BecomeLockGroupMember(PGPROC *leader, int pid); + #endif /* PROC_H */ |