PostgreSQL Source Code
git master
|
#include "lib/ilist.h"
#include "storage/lockdefs.h"
#include "storage/lwlock.h"
#include "storage/procnumber.h"
#include "storage/shmem.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | VirtualTransactionId |
struct | LockMethodData |
struct | LOCKTAG |
struct | LOCK |
struct | PROCLOCKTAG |
struct | PROCLOCK |
struct | LOCALLOCKTAG |
struct | LOCALLOCKOWNER |
struct | LOCALLOCK |
struct | LockInstanceData |
struct | LockData |
struct | BlockedProcData |
struct | BlockedProcsData |
Macros | |
#define | InvalidLocalTransactionId 0 |
#define | LocalTransactionIdIsValid(lxid) ((lxid) != InvalidLocalTransactionId) |
#define | VirtualTransactionIdIsValid(vxid) (LocalTransactionIdIsValid((vxid).localTransactionId)) |
#define | VirtualTransactionIdIsRecoveredPreparedXact(vxid) ((vxid).procNumber == INVALID_PROC_NUMBER) |
#define | VirtualTransactionIdEquals(vxid1, vxid2) |
#define | SetInvalidVirtualTransactionId(vxid) |
#define | GET_VXID_FROM_PGPROC(vxid_dst, proc) |
#define | MAX_LOCKMODES 10 |
#define | LOCKBIT_ON(lockmode) (1 << (lockmode)) |
#define | LOCKBIT_OFF(lockmode) (~(1 << (lockmode))) |
#define | DEFAULT_LOCKMETHOD 1 |
#define | USER_LOCKMETHOD 2 |
#define | LOCKTAG_LAST_TYPE LOCKTAG_APPLY_TRANSACTION |
#define | SET_LOCKTAG_RELATION(locktag, dboid, reloid) |
#define | SET_LOCKTAG_RELATION_EXTEND(locktag, dboid, reloid) |
#define | SET_LOCKTAG_DATABASE_FROZEN_IDS(locktag, dboid) |
#define | SET_LOCKTAG_PAGE(locktag, dboid, reloid, blocknum) |
#define | SET_LOCKTAG_TUPLE(locktag, dboid, reloid, blocknum, offnum) |
#define | SET_LOCKTAG_TRANSACTION(locktag, xid) |
#define | SET_LOCKTAG_VIRTUALTRANSACTION(locktag, vxid) |
#define | SET_LOCKTAG_SPECULATIVE_INSERTION(locktag, xid, token) |
#define | SET_LOCKTAG_OBJECT(locktag, dboid, classoid, objoid, objsubid) |
#define | SET_LOCKTAG_ADVISORY(locktag, id1, id2, id3, id4) |
#define | SET_LOCKTAG_APPLY_TRANSACTION(locktag, dboid, suboid, xid, objid) |
#define | LOCK_LOCKMETHOD(lock) ((LOCKMETHODID) (lock).tag.locktag_lockmethodid) |
#define | LOCK_LOCKTAG(lock) ((LockTagType) (lock).tag.locktag_type) |
#define | PROCLOCK_LOCKMETHOD(proclock) LOCK_LOCKMETHOD(*((proclock).tag.myLock)) |
#define | LOCALLOCK_LOCKMETHOD(llock) ((llock).tag.lock.locktag_lockmethodid) |
#define | LOCALLOCK_LOCKTAG(llock) ((LockTagType) (llock).tag.lock.locktag_type) |
#define | LockHashPartition(hashcode) ((hashcode) % NUM_LOCK_PARTITIONS) |
#define | LockHashPartitionLock(hashcode) |
#define | LockHashPartitionLockByIndex(i) (&MainLWLockArray[LOCK_MANAGER_LWLOCK_OFFSET + (i)].lock) |
#define | LockHashPartitionLockByProc(leader_pgproc) LockHashPartitionLock(GetNumberFromPGProc(leader_pgproc)) |
Typedefs | |
typedef struct PGPROC | PGPROC |
typedef struct LockMethodData | LockMethodData |
typedef const LockMethodData * | LockMethod |
typedef uint16 | LOCKMETHODID |
typedef enum LockTagType | LockTagType |
typedef struct LOCKTAG | LOCKTAG |
typedef struct LOCK | LOCK |
typedef struct PROCLOCKTAG | PROCLOCKTAG |
typedef struct PROCLOCK | PROCLOCK |
typedef struct LOCALLOCKTAG | LOCALLOCKTAG |
typedef struct LOCALLOCKOWNER | LOCALLOCKOWNER |
typedef struct LOCALLOCK | LOCALLOCK |
typedef struct LockInstanceData | LockInstanceData |
typedef struct LockData | LockData |
typedef struct BlockedProcData | BlockedProcData |
typedef struct BlockedProcsData | BlockedProcsData |
Variables | |
PGDLLIMPORT int | max_locks_per_xact |
PGDLLIMPORT const char *const | LockTagTypeNames [] |
#define GET_VXID_FROM_PGPROC | ( | vxid_dst, | |
proc | |||
) |
#define LOCALLOCK_LOCKMETHOD | ( | llock | ) | ((llock).tag.lock.locktag_lockmethodid) |
#define LOCALLOCK_LOCKTAG | ( | llock | ) | ((LockTagType) (llock).tag.lock.locktag_type) |
#define LocalTransactionIdIsValid | ( | lxid | ) | ((lxid) != InvalidLocalTransactionId) |
#define LOCK_LOCKMETHOD | ( | lock | ) | ((LOCKMETHODID) (lock).tag.locktag_lockmethodid) |
#define LOCK_LOCKTAG | ( | lock | ) | ((LockTagType) (lock).tag.locktag_type) |
#define LockHashPartition | ( | hashcode | ) | ((hashcode) % NUM_LOCK_PARTITIONS) |
#define LockHashPartitionLock | ( | hashcode | ) |
#define LockHashPartitionLockByIndex | ( | i | ) | (&MainLWLockArray[LOCK_MANAGER_LWLOCK_OFFSET + (i)].lock) |
#define LockHashPartitionLockByProc | ( | leader_pgproc | ) | LockHashPartitionLock(GetNumberFromPGProc(leader_pgproc)) |
#define LOCKTAG_LAST_TYPE LOCKTAG_APPLY_TRANSACTION |
#define PROCLOCK_LOCKMETHOD | ( | proclock | ) | LOCK_LOCKMETHOD(*((proclock).tag.myLock)) |
#define SET_LOCKTAG_ADVISORY | ( | locktag, | |
id1, | |||
id2, | |||
id3, | |||
id4 | |||
) |
#define SET_LOCKTAG_APPLY_TRANSACTION | ( | locktag, | |
dboid, | |||
suboid, | |||
xid, | |||
objid | |||
) |
#define SET_LOCKTAG_DATABASE_FROZEN_IDS | ( | locktag, | |
dboid | |||
) |
#define SET_LOCKTAG_OBJECT | ( | locktag, | |
dboid, | |||
classoid, | |||
objoid, | |||
objsubid | |||
) |
#define SET_LOCKTAG_PAGE | ( | locktag, | |
dboid, | |||
reloid, | |||
blocknum | |||
) |
#define SET_LOCKTAG_RELATION | ( | locktag, | |
dboid, | |||
reloid | |||
) |
#define SET_LOCKTAG_RELATION_EXTEND | ( | locktag, | |
dboid, | |||
reloid | |||
) |
#define SET_LOCKTAG_SPECULATIVE_INSERTION | ( | locktag, | |
xid, | |||
token | |||
) |
#define SET_LOCKTAG_TRANSACTION | ( | locktag, | |
xid | |||
) |
#define SET_LOCKTAG_TUPLE | ( | locktag, | |
dboid, | |||
reloid, | |||
blocknum, | |||
offnum | |||
) |
#define SET_LOCKTAG_VIRTUALTRANSACTION | ( | locktag, | |
vxid | |||
) |
#define SetInvalidVirtualTransactionId | ( | vxid | ) |
#define VirtualTransactionIdEquals | ( | vxid1, | |
vxid2 | |||
) |
#define VirtualTransactionIdIsRecoveredPreparedXact | ( | vxid | ) | ((vxid).procNumber == INVALID_PROC_NUMBER) |
#define VirtualTransactionIdIsValid | ( | vxid | ) | (LocalTransactionIdIsValid((vxid).localTransactionId)) |
typedef struct BlockedProcData BlockedProcData |
typedef struct BlockedProcsData BlockedProcsData |
typedef struct LOCALLOCKOWNER LOCALLOCKOWNER |
typedef struct LOCALLOCKTAG LOCALLOCKTAG |
typedef struct LockInstanceData LockInstanceData |
typedef const LockMethodData* LockMethod |
typedef struct LockMethodData LockMethodData |
typedef uint16 LOCKMETHODID |
typedef enum LockTagType LockTagType |
typedef struct PROCLOCKTAG PROCLOCKTAG |
enum DeadLockState |
enum LockAcquireResult |
enum LockTagType |
void AbortStrongLockAcquire | ( | void | ) |
Definition at line 1809 of file lock.c.
References Assert, FastPathStrongRelationLockData::count, FastPathStrongLockHashPartition, FastPathStrongRelationLocks, LOCALLOCK::hashcode, LOCALLOCK::holdsStrongLockCount, FastPathStrongRelationLockData::mutex, SpinLockAcquire, SpinLockRelease, and StrongLockInProgress.
Referenced by LockAcquireExtended(), and LockErrorCleanup().
void AtPrepare_Locks | ( | void | ) |
Definition at line 3383 of file lock.c.
References CheckForSessionAndXactLocks(), ereport, errcode(), errmsg(), ERROR, FastPathGetRelationLockEntry(), hash_seq_init(), hash_seq_search(), LOCALLOCK::holdsStrongLockCount, i, LOCALLOCKTAG::lock, LOCALLOCK::lock, LockMethodLocalHash, TwoPhaseLockRecord::lockmode, LOCALLOCK::lockOwners, TwoPhaseLockRecord::locktag, LOCKTAG::locktag_type, LOCKTAG_VIRTUALTRANSACTION, LOCALLOCKTAG::mode, PROCLOCKTAG::myLock, LOCALLOCK::nLocks, LOCALLOCK::numLockOwners, LOCALLOCK::proclock, RegisterTwoPhaseRecord(), PROCLOCK::tag, LOCALLOCK::tag, and TWOPHASE_RM_LOCK_ID.
Referenced by PrepareTransaction().
DeadLockState DeadLockCheck | ( | PGPROC * | proc | ) |
Definition at line 217 of file deadlock.c.
References Assert, blocking_autovacuum_proc, dclist_count(), dclist_init(), dclist_push_tail(), DeadLockCheckRecurse(), DS_BLOCKED_BY_AUTOVACUUM, DS_HARD_DEADLOCK, DS_NO_DEADLOCK, DS_SOFT_DEADLOCK, elog, FATAL, FindLockCycle(), GetLocksMethodTable(), i, j, links, WAIT_ORDER::lock, nCurConstraints, nPossibleConstraints, WAIT_ORDER::nProcs, nWaitOrders, possibleConstraints, ProcLockWakeup(), WAIT_ORDER::procs, waitOrders, and LOCK::waitProcs.
Referenced by CheckDeadLock().
void DeadLockReport | ( | void | ) |
Definition at line 1072 of file deadlock.c.
References _, appendBinaryStringInfo(), appendStringInfo(), appendStringInfoChar(), StringInfoData::data, deadlockDetails, DescribeLockTag(), ereport, errcode(), ERRCODE_T_R_DEADLOCK_DETECTED, errdetail_internal(), errdetail_log(), errhint(), errmsg(), ERROR, GetLockmodeName(), i, initStringInfo(), StringInfoData::len, DEADLOCK_INFO::lockmode, DEADLOCK_INFO::locktag, LOCKTAG::locktag_lockmethodid, nDeadlockDetails, pgstat_get_backend_current_activity(), pgstat_report_deadlock(), DEADLOCK_INFO::pid, and resetStringInfo().
Referenced by LockAcquireExtended().
Definition at line 617 of file lock.c.
References LockMethodData::conflictTab, DEFAULT_LOCKMETHOD, LOCKBIT_ON, and LockMethods.
Referenced by Do_MultiXactIdWait(), DoesMultiXactIdConflict(), initialize_reloptions(), and test_lockmode_for_conflict().
LOCALLOCK* GetAwaitedLock | ( | void | ) |
Definition at line 1847 of file lock.c.
References awaitedLock.
Referenced by LockErrorCleanup(), ProcessRecoveryConflictInterrupt(), and ProcSleep().
BlockedProcsData* GetBlockerStatusData | ( | int | blocked_pid | ) |
Definition at line 3903 of file lock.c.
References Assert, BackendPidGetProcWithLock(), dlist_iter::cur, data, dlist_container, dlist_foreach, GetSingleProcBlockerStatusData(), i, PGPROC::lockGroupLeader, PGPROC::lockGroupMembers, LockHashPartitionLockByIndex, LW_SHARED, LWLockAcquire(), LWLockRelease(), MaxBackends, NUM_LOCK_PARTITIONS, and palloc().
Referenced by pg_blocking_pids().
PGPROC* GetBlockingAutoVacuumPgproc | ( | void | ) |
Definition at line 287 of file deadlock.c.
References blocking_autovacuum_proc.
Referenced by ProcSleep().
VirtualTransactionId* GetLockConflicts | ( | const LOCKTAG * | locktag, |
LOCKMODE | lockmode, | ||
int * | countp | ||
) |
Definition at line 2976 of file lock.c.
References PROC_HDR::allProcCount, PROC_HDR::allProcs, ConflictsWithRelationFastPath, LockMethodData::conflictTab, dlist_iter::cur, PGPROC::databaseId, dlist_container, dlist_foreach, elog, ERROR, FAST_PATH_GET_BITS, FAST_PATH_LOCKNUMBER_OFFSET, FAST_PATH_REL_GROUP, FAST_PATH_SLOT, FP_LOCK_SLOTS_PER_GROUP, PGPROC::fpInfoLock, PGPROC::fpRelId, GET_VXID_FROM_PGPROC, HASH_FIND, hash_search_with_hash_value(), PROCLOCK::holdMask, i, InHotStandby, INVALID_PROC_NUMBER, InvalidLocalTransactionId, j, lengthof, VirtualTransactionId::localTransactionId, LockHashPartitionLock, LockMethodLockHash, LockMethods, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_lockmethodid, LockTagHashCode(), LW_SHARED, LWLockAcquire(), LWLockRelease(), max_prepared_xacts, MaxBackends, MemoryContextAlloc(), MyProc, PROCLOCKTAG::myProc, LockMethodData::numLockModes, palloc0(), PANIC, ProcGlobal, LOCK::procLocks, VirtualTransactionId::procNumber, PROCLOCK::tag, TopMemoryContext, VirtualTransactionIdEquals, and VirtualTransactionIdIsValid.
Referenced by ProcSleep(), ResolveRecoveryConflictWithLock(), and WaitForLockersMultiple().
const char* GetLockmodeName | ( | LOCKMETHODID | lockmethodid, |
LOCKMODE | mode | ||
) |
Definition at line 4160 of file lock.c.
References Assert, lengthof, LockMethods, LockMethodData::lockModeNames, and mode.
Referenced by DeadLockReport(), pg_lock_status(), and ProcSleep().
LockMethod GetLocksMethodTable | ( | const LOCK * | lock | ) |
Definition at line 521 of file lock.c.
References Assert, lengthof, LOCK_LOCKMETHOD, and LockMethods.
Referenced by DeadLockCheck(), and FindLockCycleRecurseMember().
LockData* GetLockStatusData | ( | void | ) |
Definition at line 3700 of file lock.c.
References PROC_HDR::allProcCount, PROC_HDR::allProcs, Assert, data, PGPROC::databaseId, ExclusiveLock, FAST_PATH_GET_BITS, FAST_PATH_LOCKNUMBER_OFFSET, FAST_PATH_SLOT, LockInstanceData::fastpath, FastPathLockGroupsPerBackend, FP_LOCK_SLOTS_PER_GROUP, PGPROC::fpInfoLock, PGPROC::fpLocalTransactionId, PGPROC::fpLockBits, PGPROC::fpRelId, PGPROC::fpVXIDLock, PROCLOCK::groupLeader, hash_get_num_entries(), hash_seq_init(), hash_seq_search(), PROCLOCK::holdMask, LockInstanceData::holdMask, i, j, LockInstanceData::leaderPid, VirtualTransactionId::localTransactionId, LOCKBIT_ON, LockHashPartitionLockByIndex, LockMethodProcLockHash, LockInstanceData::locktag, LW_SHARED, LWLockAcquire(), LWLockRelease(), PGPROC::lxid, MaxBackends, PROCLOCKTAG::myLock, PROCLOCKTAG::myProc, NoLock, NUM_LOCK_PARTITIONS, palloc(), pg_atomic_read_u64(), LockInstanceData::pid, PGPROC::pid, ProcGlobal, VirtualTransactionId::procNumber, PGPROC::procNumber, repalloc(), SET_LOCKTAG_RELATION, SET_LOCKTAG_VIRTUALTRANSACTION, LOCK::tag, PROCLOCK::tag, LockInstanceData::vxid, PGPROC::vxid, PGPROC::waitLock, LockInstanceData::waitLockMode, PGPROC::waitLockMode, LockInstanceData::waitStart, and PGPROC::waitStart.
Referenced by pg_lock_status().
LockMethod GetLockTagsMethodTable | ( | const LOCKTAG * | locktag | ) |
Definition at line 533 of file lock.c.
References Assert, lengthof, LockMethods, and LOCKTAG::locktag_lockmethodid.
Referenced by pg_blocking_pids().
xl_standby_lock* GetRunningTransactionLocks | ( | int * | nlocks | ) |
Definition at line 4078 of file lock.c.
References AccessExclusiveLock, Assert, xl_standby_lock::dbOid, hash_get_num_entries(), hash_seq_init(), hash_seq_search(), PROCLOCK::holdMask, i, LOCKBIT_ON, LockHashPartitionLockByIndex, LockMethodProcLockHash, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG_RELATION, LOCKTAG::locktag_type, LW_SHARED, LWLockAcquire(), LWLockRelease(), PROCLOCKTAG::myLock, PROCLOCKTAG::myProc, NUM_LOCK_PARTITIONS, palloc(), xl_standby_lock::relOid, LOCK::tag, PROCLOCK::tag, TransactionIdIsValid, xl_standby_lock::xid, and PGPROC::xid.
Referenced by LogStandbySnapshot().
void GrantAwaitedLock | ( | void | ) |
Definition at line 1838 of file lock.c.
References awaitedLock, awaitedOwner, and GrantLockLocal().
Referenced by LockErrorCleanup().
Definition at line 1607 of file lock.c.
References Assert, LOCK::granted, LOCK::grantMask, PROCLOCK::holdMask, LOCK_PRINT, LOCKBIT_OFF, LOCKBIT_ON, LOCK::nGranted, LOCK::nRequested, LOCK::requested, and LOCK::waitMask.
Referenced by FastPathGetRelationLockEntry(), FastPathTransferRelationLocks(), JoinWaitQueue(), lock_twophase_recover(), LockAcquireExtended(), ProcLockWakeup(), and VirtualXactLock().
void InitDeadLockChecking | ( | void | ) |
Definition at line 143 of file deadlock.c.
References afterConstraints, beforeConstraints, curConstraints, deadlockDetails, MaxBackends, maxCurConstraints, maxPossibleConstraints, MemoryContextSwitchTo(), palloc(), possibleConstraints, TopMemoryContext, topoProcs, visitedProcs, waitOrderProcs, and waitOrders.
Referenced by InitProcess().
void InitLockManagerAccess | ( | void | ) |
Definition at line 499 of file lock.c.
References HASHCTL::entrysize, HASH_BLOBS, hash_create(), HASH_ELEM, HASHCTL::keysize, and LockMethodLocalHash.
Referenced by BaseInit().
void lock_twophase_postabort | ( | TransactionId | xid, |
uint16 | info, | ||
void * | recdata, | ||
uint32 | len | ||
) |
Definition at line 4503 of file lock.c.
References len, and lock_twophase_postcommit().
void lock_twophase_postcommit | ( | TransactionId | xid, |
uint16 | info, | ||
void * | recdata, | ||
uint32 | len | ||
) |
Definition at line 4477 of file lock.c.
References Assert, elog, ERROR, len, lengthof, LockMethods, TwoPhaseLockRecord::lockmode, LockRefindAndRelease(), TwoPhaseLockRecord::locktag, LOCKTAG::locktag_lockmethodid, and TwoPhaseGetDummyProc().
Referenced by lock_twophase_postabort().
void lock_twophase_recover | ( | TransactionId | xid, |
uint16 | info, | ||
void * | recdata, | ||
uint32 | len | ||
) |
Definition at line 4264 of file lock.c.
References Assert, ConflictsWithRelationFastPath, FastPathStrongRelationLockData::count, dclist_init(), dlist_init(), dlist_is_empty(), dlist_push_tail(), elog, ereport, errcode(), errhint(), errmsg(), ERROR, FastPathStrongLockHashPartition, FastPathStrongRelationLocks, LOCK::granted, GrantLock(), LOCK::grantMask, PROCLOCK::groupLeader, HASH_ENTER_NULL, HASH_REMOVE, hash_search_with_hash_value(), PROCLOCK::holdMask, len, lengthof, LOCK_PRINT, LOCKBIT_ON, PGPROC::lockGroupLeader, LockHashPartition, LockHashPartitionLock, PROCLOCK::lockLink, LockMethodLockHash, LockMethodProcLockHash, LockMethods, TwoPhaseLockRecord::lockmode, LockMethodData::lockModeNames, TwoPhaseLockRecord::locktag, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_field3, LOCKTAG::locktag_lockmethodid, LockTagHashCode(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAX_LOCKMODES, MemSet, FastPathStrongRelationLockData::mutex, PROCLOCKTAG::myLock, PROCLOCKTAG::myProc, PGPROC::myProcLocks, LOCK::nGranted, LOCK::nRequested, PANIC, PROCLOCK::procLink, PROCLOCK_PRINT, ProcLockHashCode(), LOCK::procLocks, PROCLOCK::releaseMask, LOCK::requested, SpinLockAcquire, SpinLockRelease, LOCK::tag, TwoPhaseGetDummyProc(), LOCK::waitMask, and LOCK::waitProcs.
void lock_twophase_standby_recover | ( | TransactionId | xid, |
uint16 | info, | ||
void * | recdata, | ||
uint32 | len | ||
) |
Definition at line 4445 of file lock.c.
References AccessExclusiveLock, Assert, elog, ERROR, len, lengthof, LockMethods, TwoPhaseLockRecord::lockmode, TwoPhaseLockRecord::locktag, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_lockmethodid, LOCKTAG_RELATION, LOCKTAG::locktag_type, and StandbyAcquireAccessExclusiveLock().
LockAcquireResult LockAcquire | ( | const LOCKTAG * | locktag, |
LOCKMODE | lockmode, | ||
bool | sessionLock, | ||
bool | dontWait | ||
) |
Definition at line 803 of file lock.c.
References LockAcquireExtended().
Referenced by ConditionalLockPage(), ConditionalLockRelationForExtension(), ConditionalLockTuple(), ConditionalXactLockTableWait(), LockApplyTransactionForSession(), LockDatabaseFrozenIds(), LockDatabaseObject(), LockPage(), LockRelationForExtension(), LockRelationIdForSession(), LockSharedObject(), LockSharedObjectForSession(), LockTuple(), pg_advisory_lock_int4(), pg_advisory_lock_int8(), pg_advisory_lock_shared_int4(), pg_advisory_lock_shared_int8(), pg_advisory_xact_lock_int4(), pg_advisory_xact_lock_int8(), pg_advisory_xact_lock_shared_int4(), pg_advisory_xact_lock_shared_int8(), pg_try_advisory_lock_int4(), pg_try_advisory_lock_int8(), pg_try_advisory_lock_shared_int4(), pg_try_advisory_lock_shared_int8(), pg_try_advisory_xact_lock_int4(), pg_try_advisory_xact_lock_int8(), pg_try_advisory_xact_lock_shared_int4(), pg_try_advisory_xact_lock_shared_int8(), SearchSysCacheLocked1(), SpeculativeInsertionLockAcquire(), SpeculativeInsertionWait(), StandbyAcquireAccessExclusiveLock(), VirtualXactLock(), XactLockForVirtualXact(), XactLockTableInsert(), and XactLockTableWait().
LockAcquireResult LockAcquireExtended | ( | const LOCKTAG * | locktag, |
LOCKMODE | lockmode, | ||
bool | sessionLock, | ||
bool | dontWait, | ||
bool | reportMemoryError, | ||
LOCALLOCK ** | locallockp | ||
) |
Definition at line 827 of file lock.c.
References AbortStrongLockAcquire(), AccessExclusiveLock, Assert, BeginStrongLockAcquire(), ConflictsWithRelationFastPath, LockMethodData::conflictTab, FastPathStrongRelationLockData::count, CurrentResourceOwner, DeadLockReport(), dlist_delete(), EligibleForRelationFastPath, elog, ereport, errcode(), errhint(), errmsg(), ERROR, FAST_PATH_REL_GROUP, FastPathGrantRelationLock(), FastPathLocalUseCounts, FastPathStrongLockHashPartition, FastPathStrongRelationLocks, FastPathTransferRelationLocks(), FinishStrongLockAcquire(), FP_LOCK_SLOTS_PER_GROUP, PGPROC::fpInfoLock, GrantLock(), GrantLockLocal(), HASH_ENTER, HASH_REMOVE, hash_search(), hash_search_with_hash_value(), LOCALLOCK::hashcode, PROCLOCK::holdMask, LOCALLOCK::holdsStrongLockCount, InRecovery, JoinWaitQueue(), lengthof, LOCALLOCKTAG::lock, LOCALLOCK::lock, LOCK_PRINT, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_ALREADY_HELD, LOCKACQUIRE_NOT_AVAIL, LOCKACQUIRE_OK, LOCKBIT_ON, LockCheckConflicts(), LOCALLOCK::lockCleared, LockHashPartitionLock, PROCLOCK::lockLink, LockMethodLocalHash, LockMethodProcLockHash, LockMethods, LockMethodData::lockModeNames, LOCALLOCK::lockOwners, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_lockmethodid, LOCKTAG_OBJECT, LOCKTAG_RELATION, LOCKTAG::locktag_type, LockTagHashCode(), LOG, LogAccessExclusiveLock(), LogAccessExclusiveLockPrepare(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), LOCALLOCK::maxLockOwners, MemoryContextAlloc(), MemSet, LOCALLOCKTAG::mode, PROCLOCKTAG::myLock, MyProc, LOCK::nGranted, LOCALLOCK::nLocks, LOCK::nRequested, LockMethodData::numLockModes, LOCALLOCK::numLockOwners, PANIC, PROC_WAIT_STATUS_ERROR, PROC_WAIT_STATUS_OK, PROC_WAIT_STATUS_WAITING, PROCLOCK::procLink, LOCALLOCK::proclock, PROCLOCK_PRINT, ProcLockHashCode(), RecoveryInProgress(), RemoveLocalLock(), repalloc(), LOCK::requested, RowExclusiveLock, SetupLockInTable(), PROCLOCK::tag, TopMemoryContext, LOCK::waitMask, WaitOnLock(), and XLogStandbyInfoActive.
Referenced by ConditionalLockDatabaseObject(), ConditionalLockRelation(), ConditionalLockRelationOid(), ConditionalLockSharedObject(), LockAcquire(), LockRelation(), LockRelationId(), and LockRelationOid().
bool LockCheckConflicts | ( | LockMethod | lockMethodTable, |
LOCKMODE | lockmode, | ||
LOCK * | lock, | ||
PROCLOCK * | proclock | ||
) |
Definition at line 1478 of file lock.c.
References Assert, LockMethodData::conflictTab, dlist_iter::cur, dlist_container, dlist_foreach, elog, LOCK::granted, LOCK::grantMask, PROCLOCK::groupLeader, PROCLOCK::holdMask, i, LOCK_LOCKTAG, LOCKBIT_ON, PGPROC::lockGroupLeader, LOCKTAG_RELATION_EXTEND, MAX_LOCKMODES, MyProc, PROCLOCKTAG::myProc, LockMethodData::numLockModes, PANIC, PROCLOCK_PRINT, LOCK::procLocks, and PROCLOCK::tag.
Referenced by JoinWaitQueue(), LockAcquireExtended(), and ProcLockWakeup().
Definition at line 690 of file lock.c.
References LockMethodData::conflictTab, elog, ERROR, HASH_FIND, hash_search(), LOCALLOCK::hashcode, PROCLOCK::holdMask, lengthof, LOCALLOCKTAG::lock, LOCALLOCK::lock, LOCK_PRINT, LOCKBIT_ON, LockHashPartitionLock, LockMethodLocalHash, LockMethods, LockMethodData::lockModeNames, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_lockmethodid, LOG, LW_SHARED, LWLockAcquire(), LWLockRelease(), MemSet, LOCALLOCKTAG::mode, LOCALLOCK::nLocks, LockMethodData::numLockModes, LOCALLOCK::proclock, PROCLOCK_PRINT, RemoveLocalLock(), LOCK::waitMask, and WARNING.
Referenced by LockHasWaitersRelation().
Definition at line 637 of file lock.c.
References HASH_FIND, hash_search(), LOCALLOCKTAG::lock, LockMethodLocalHash, MaxLockMode, MemSet, LOCALLOCKTAG::mode, and LOCALLOCK::nLocks.
Referenced by CheckRelationLockedByMe(), and CheckRelationOidLockedByMe().
void LockManagerShmemInit | ( | void | ) |
Definition at line 438 of file lock.c.
References HASHCTL::entrysize, FastPathStrongRelationLocks, HASHCTL::hash, HASH_BLOBS, HASH_ELEM, HASH_FUNCTION, HASH_PARTITION, HASHCTL::keysize, LockMethodLockHash, LockMethodProcLockHash, FastPathStrongRelationLockData::mutex, NLOCKENTS, NUM_LOCK_PARTITIONS, HASHCTL::num_partitions, proclock_hash(), ShmemInitHash(), ShmemInitStruct(), and SpinLockInit.
Referenced by CreateOrAttachShmemStructs().
Size LockManagerShmemSize | ( | void | ) |
Definition at line 3663 of file lock.c.
References add_size(), hash_estimate_size(), NLOCKENTS, and size.
Referenced by CalculateShmemSize().
void LockReassignCurrentOwner | ( | LOCALLOCK ** | locallocks, |
int | nlocks | ||
) |
Definition at line 2615 of file lock.c.
References Assert, CurrentResourceOwner, hash_seq_init(), hash_seq_search(), i, LockMethodLocalHash, LockReassignOwner(), and ResourceOwnerGetParent().
Referenced by ResourceOwnerReleaseInternal().
Definition at line 2011 of file lock.c.
References Assert, CleanUpLock(), CurrentResourceOwner, EligibleForRelationFastPath, elog, ERROR, FAST_PATH_REL_GROUP, FastPathLocalUseCounts, FastPathUnGrantRelationLock(), PGPROC::fpInfoLock, HASH_FIND, hash_search(), hash_search_with_hash_value(), LOCALLOCK::hashcode, PROCLOCK::holdMask, i, lengthof, LOCALLOCKTAG::lock, LOCALLOCK::lock, LOCK_PRINT, LOCKBIT_ON, LOCALLOCK::lockCleared, LockHashPartitionLock, LockMethodLocalHash, LockMethodLockHash, LockMethodProcLockHash, LockMethods, LockMethodData::lockModeNames, LOCALLOCK::lockOwners, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_lockmethodid, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MemSet, LOCALLOCKTAG::mode, PROCLOCKTAG::myLock, MyProc, PROCLOCKTAG::myProc, LOCALLOCK::nLocks, LockMethodData::numLockModes, LOCALLOCK::numLockOwners, LOCALLOCK::proclock, PROCLOCK_PRINT, RemoveLocalLock(), ResourceOwnerForgetLock(), UnGrantLock(), and WARNING.
Referenced by ConditionalXactLockTableWait(), pg_advisory_unlock_int4(), pg_advisory_unlock_int8(), pg_advisory_unlock_shared_int4(), pg_advisory_unlock_shared_int8(), ReleaseLockIfHeld(), SearchSysCacheLocked1(), SpeculativeInsertionLockRelease(), SpeculativeInsertionWait(), StandbyReleaseXidEntryLocks(), UnlockApplyTransactionForSession(), UnlockDatabaseObject(), UnlockPage(), UnlockRelation(), UnlockRelationForExtension(), UnlockRelationId(), UnlockRelationIdForSession(), UnlockRelationOid(), UnlockSharedObject(), UnlockSharedObjectForSession(), UnlockTuple(), VirtualXactLock(), XactLockForVirtualXact(), XactLockTableDelete(), and XactLockTableWait().
void LockReleaseAll | ( | LOCKMETHODID | lockmethodid, |
bool | allLocks | ||
) |
Definition at line 2216 of file lock.c.
References Assert, CleanUpLock(), dlist_mutable_iter::cur, DEFAULT_LOCKMETHOD, dlist_container, dlist_foreach_modify, dlist_is_empty(), EligibleForRelationFastPath, elog, ERROR, FastPathUnGrantRelationLock(), PGPROC::fpInfoLock, LOCK::grantMask, hash_seq_init(), hash_seq_search(), PROCLOCK::holdMask, i, lengthof, LOCALLOCK_LOCKMETHOD, LOCALLOCK_LOCKTAG, LOCALLOCKTAG::lock, LOCALLOCK::lock, LOCK_LOCKMETHOD, LOCK_PRINT, LOCKBIT_ON, LockHashPartitionLockByIndex, LockMethodLocalHash, LockMethods, LOCALLOCK::lockOwners, LockRefindAndRelease(), LOCKTAG::locktag_field2, LOCKTAG_TUPLE, LockTagHashCode(), LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), LOCALLOCKTAG::mode, PROCLOCKTAG::myLock, MyProc, PROCLOCKTAG::myProc, PGPROC::myProcLocks, LOCK::nGranted, LOCALLOCKOWNER::nLocks, LOCALLOCK::nLocks, LOCK::nRequested, NUM_LOCK_PARTITIONS, LockMethodData::numLockModes, LOCALLOCK::numLockOwners, LOCALLOCKOWNER::owner, PANIC, LOCALLOCK::proclock, PROCLOCK_PRINT, PROCLOCK::releaseMask, RemoveLocalLock(), ResourceOwnerForgetLock(), LOCK::tag, PROCLOCK::tag, LOCALLOCK::tag, LockMethodData::trace_flag, UnGrantLock(), VirtualXactLockTableCleanup(), and WARNING.
Referenced by DiscardAll(), logicalrep_worker_onexit(), ProcReleaseLocks(), and ShutdownPostgres().
void LockReleaseCurrentOwner | ( | LOCALLOCK ** | locallocks, |
int | nlocks | ||
) |
Definition at line 2520 of file lock.c.
References hash_seq_init(), hash_seq_search(), i, LockMethodLocalHash, and ReleaseLockIfHeld().
Referenced by ResourceOwnerReleaseInternal().
void LockReleaseSession | ( | LOCKMETHODID | lockmethodid | ) |
Definition at line 2490 of file lock.c.
References elog, ERROR, hash_seq_init(), hash_seq_search(), lengthof, LOCALLOCK_LOCKMETHOD, LockMethodLocalHash, LockMethods, and ReleaseLockIfHeld().
Referenced by pg_advisory_unlock_all().
Definition at line 551 of file lock.c.
References get_hash_value(), and LockMethodLockHash.
Referenced by CheckDeadLock(), GetLockConflicts(), lock_twophase_recover(), LockAcquireExtended(), LockRefindAndRelease(), LockReleaseAll(), LockWaiterCount(), proclock_hash(), and VirtualXactLock().
int LockWaiterCount | ( | const LOCKTAG * | locktag | ) |
Definition at line 4761 of file lock.c.
References Assert, elog, ERROR, HASH_FIND, hash_search_with_hash_value(), lengthof, LockHashPartitionLock, LockMethodLockHash, LockMethods, LOCKTAG::locktag_lockmethodid, LockTagHashCode(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), and LOCK::nRequested.
Referenced by RelationExtensionLockWaiterCount().
void MarkLockClear | ( | LOCALLOCK * | locallock | ) |
Definition at line 1860 of file lock.c.
References Assert, LOCALLOCK::lockCleared, and LOCALLOCK::nLocks.
Referenced by ConditionalLockDatabaseObject(), ConditionalLockRelation(), ConditionalLockRelationOid(), ConditionalLockSharedObject(), LockRelation(), LockRelationId(), and LockRelationOid().
void PostPrepare_Locks | ( | TransactionId | xid | ) |
Definition at line 3479 of file lock.c.
References Assert, dlist_mutable_iter::cur, dlist_container, dlist_delete(), dlist_foreach_modify, dlist_is_empty(), dlist_push_tail(), elog, END_CRIT_SECTION, ereport, errcode(), errmsg(), LOCK::grantMask, PROCLOCK::groupLeader, hash_seq_init(), hash_seq_search(), hash_update_hash_key(), PROCLOCK::holdMask, i, LOCALLOCKTAG::lock, LOCALLOCK::lock, LOCK_PRINT, LOCKBIT_ON, PGPROC::lockGroupLeader, LockHashPartitionLockByIndex, LockMethodLocalHash, LockMethodProcLockHash, LOCALLOCK::lockOwners, LOCKTAG::locktag_type, LOCKTAG_VIRTUALTRANSACTION, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), LOCALLOCKTAG::mode, PROCLOCKTAG::myLock, MyProc, PROCLOCKTAG::myProc, PGPROC::myProcLocks, LOCK::nGranted, LOCALLOCK::nLocks, LOCK::nRequested, NUM_LOCK_PARTITIONS, LOCALLOCK::numLockOwners, PANIC, PROCLOCK::procLink, LOCALLOCK::proclock, PROCLOCK_PRINT, PROCLOCK::releaseMask, RemoveLocalLock(), START_CRIT_SECTION, LOCK::tag, PROCLOCK::tag, LOCALLOCK::tag, and TwoPhaseGetDummyProc().
Referenced by PrepareTransaction().
Definition at line 1144 of file deadlock.c.
References deadlockDetails, DEADLOCK_INFO::lockmode, DEADLOCK_INFO::locktag, nDeadlockDetails, DEADLOCK_INFO::pid, PGPROC::pid, LOCK::tag, PGPROC::waitLock, and PGPROC::waitLockMode.
Referenced by JoinWaitQueue().
Definition at line 1955 of file lock.c.
References Assert, CleanUpLock(), dclist_delete_from_thoroughly(), dclist_is_empty(), LOCK::granted, lengthof, PGPROC::links, LOCK_LOCKMETHOD, LOCKBIT_OFF, LockMethods, dlist_node::next, LOCK::nGranted, LOCK::nRequested, PROC_WAIT_STATUS_ERROR, PROC_WAIT_STATUS_WAITING, LOCK::requested, PGPROC::waitLock, PGPROC::waitLockMode, LOCK::waitMask, PGPROC::waitProcLock, LOCK::waitProcs, and PGPROC::waitStatus.
Referenced by CheckDeadLock(), and LockErrorCleanup().
bool VirtualXactLock | ( | VirtualTransactionId | vxid, |
bool | wait | ||
) |
Definition at line 4650 of file lock.c.
References Assert, DEFAULT_LOCKMETHOD, ereport, errcode(), errhint(), errmsg(), ERROR, ExclusiveLock, PGPROC::fpInfoLock, PGPROC::fpLocalTransactionId, PGPROC::fpVXIDLock, GrantLock(), InvalidTransactionId, VirtualTransactionId::localTransactionId, LockAcquire(), LockHashPartitionLock, LockMethods, LockRelease(), LockTagHashCode(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), PROCLOCKTAG::myLock, VirtualTransactionId::procNumber, PGPROC::procNumber, ProcNumberGetProc(), SET_LOCKTAG_VIRTUALTRANSACTION, SetupLockInTable(), ShareLock, PROCLOCK::tag, VirtualTransactionIdIsRecoveredPreparedXact, VirtualTransactionIdIsValid, PGPROC::vxid, XactLockForVirtualXact(), and PGPROC::xid.
Referenced by ResolveRecoveryConflictWithVirtualXIDs(), WaitForLockersMultiple(), and WaitForOlderSnapshots().
void VirtualXactLockTableCleanup | ( | void | ) |
Definition at line 4550 of file lock.c.
References Assert, DEFAULT_LOCKMETHOD, ExclusiveLock, PGPROC::fpInfoLock, PGPROC::fpLocalTransactionId, PGPROC::fpVXIDLock, INVALID_PROC_NUMBER, InvalidLocalTransactionId, VirtualTransactionId::localTransactionId, LocalTransactionIdIsValid, LockMethods, LockRefindAndRelease(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, MyProcNumber, VirtualTransactionId::procNumber, PGPROC::procNumber, SET_LOCKTAG_VIRTUALTRANSACTION, and PGPROC::vxid.
Referenced by LockReleaseAll(), and ShutdownRecoveryTransactionEnvironment().
void VirtualXactLockTableInsert | ( | VirtualTransactionId | vxid | ) |
Definition at line 4527 of file lock.c.
References Assert, PGPROC::fpInfoLock, PGPROC::fpLocalTransactionId, PGPROC::fpVXIDLock, InvalidLocalTransactionId, VirtualTransactionId::localTransactionId, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, VirtualTransactionId::procNumber, PGPROC::procNumber, VirtualTransactionIdIsValid, and PGPROC::vxid.
Referenced by InitRecoveryTransactionEnvironment(), and StartTransaction().
|
extern |
Definition at line 28 of file lockfuncs.c.
Referenced by GetLockNameFromTagType(), and pg_lock_status().
|
extern |
Definition at line 52 of file lock.c.
Referenced by CheckRequiredParameterValues(), InitControlFile(), InitializeFastPathLocks(), and XLogReportParameters().