PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "pgstat.h"
#include "storage/lmgr.h"
#include "storage/proc.h"
#include "utils/memutils.h"
Go to the source code of this file.
Data Structures | |
struct | EDGE |
struct | WAIT_ORDER |
struct | DEADLOCK_INFO |
Functions | |
static bool | DeadLockCheckRecurse (PGPROC *proc) |
static int | TestConfiguration (PGPROC *startProc) |
static bool | FindLockCycle (PGPROC *checkProc, EDGE *softEdges, int *nSoftEdges) |
static bool | FindLockCycleRecurse (PGPROC *checkProc, int depth, EDGE *softEdges, int *nSoftEdges) |
static bool | FindLockCycleRecurseMember (PGPROC *checkProc, PGPROC *checkProcLeader, int depth, EDGE *softEdges, int *nSoftEdges) |
static bool | ExpandConstraints (EDGE *constraints, int nConstraints) |
static bool | TopoSort (LOCK *lock, EDGE *constraints, int nConstraints, PGPROC **ordering) |
void | InitDeadLockChecking (void) |
DeadLockState | DeadLockCheck (PGPROC *proc) |
PGPROC * | GetBlockingAutoVacuumPgproc (void) |
void | DeadLockReport (void) |
void | RememberSimpleDeadLock (PGPROC *proc1, LOCKMODE lockmode, LOCK *lock, PGPROC *proc2) |
Variables | |
static PGPROC ** | visitedProcs |
static int | nVisitedProcs |
static PGPROC ** | topoProcs |
static int * | beforeConstraints |
static int * | afterConstraints |
static WAIT_ORDER * | waitOrders |
static int | nWaitOrders |
static PGPROC ** | waitOrderProcs |
static EDGE * | curConstraints |
static int | nCurConstraints |
static int | maxCurConstraints |
static EDGE * | possibleConstraints |
static int | nPossibleConstraints |
static int | maxPossibleConstraints |
static DEADLOCK_INFO * | deadlockDetails |
static int | nDeadlockDetails |
static PGPROC * | blocking_autovacuum_proc = NULL |
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().
|
static |
Definition at line 309 of file deadlock.c.
References curConstraints, elog, FATAL, i, MaxBackends, maxCurConstraints, maxPossibleConstraints, nCurConstraints, nPossibleConstraints, possibleConstraints, and TestConfiguration().
Referenced by DeadLockCheck().
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().
|
static |
Definition at line 787 of file deadlock.c.
References Assert, dclist_count(), i, j, EDGE::lock, WAIT_ORDER::lock, MaxBackends, WAIT_ORDER::nProcs, nWaitOrders, WAIT_ORDER::procs, TopoSort(), waitOrderProcs, waitOrders, and LOCK::waitProcs.
Referenced by TestConfiguration().
Definition at line 443 of file deadlock.c.
References FindLockCycleRecurse(), nDeadlockDetails, and nVisitedProcs.
Referenced by DeadLockCheck(), and TestConfiguration().
|
static |
Definition at line 454 of file deadlock.c.
References Assert, dlist_iter::cur, dlist_container, dlist_foreach, FindLockCycleRecurseMember(), i, PGPROC::links, PGPROC::lockGroupLeader, PGPROC::lockGroupMembers, MaxBackends, nDeadlockDetails, dlist_node::next, nVisitedProcs, visitedProcs, and PGPROC::waitLock.
Referenced by FindLockCycle(), and FindLockCycleRecurseMember().
|
static |
Definition at line 533 of file deadlock.c.
References Assert, EDGE::blocker, blocking_autovacuum_proc, LockMethodData::conflictTab, dlist_iter::cur, dclist_foreach, deadlockDetails, dlist_container, dlist_foreach, FindLockCycleRecurse(), GetLocksMethodTable(), PROCLOCK::holdMask, i, links, EDGE::lock, LOCK_LOCKTAG, LOCKBIT_ON, PGPROC::lockGroupLeader, DEADLOCK_INFO::lockmode, DEADLOCK_INFO::locktag, LOCKTAG_RELATION_EXTEND, MaxBackends, MyProc, PROCLOCKTAG::myProc, WAIT_ORDER::nProcs, LockMethodData::numLockModes, nWaitOrders, DEADLOCK_INFO::pid, PGPROC::pid, PROC_IS_AUTOVACUUM, LOCK::procLocks, WAIT_ORDER::procs, PGPROC::statusFlags, LOCK::tag, PROCLOCK::tag, EDGE::waiter, PGPROC::waitLock, PGPROC::waitLockMode, waitOrders, and LOCK::waitProcs.
Referenced by FindLockCycleRecurse().
PGPROC* GetBlockingAutoVacuumPgproc | ( | void | ) |
Definition at line 287 of file deadlock.c.
References blocking_autovacuum_proc.
Referenced by ProcSleep().
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().
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().
|
static |
Definition at line 375 of file deadlock.c.
References curConstraints, ExpandConstraints(), FindLockCycle(), i, MaxBackends, maxPossibleConstraints, nCurConstraints, nPossibleConstraints, and possibleConstraints.
Referenced by DeadLockCheckRecurse().
|
static |
Definition at line 859 of file deadlock.c.
References afterConstraints, Assert, beforeConstraints, EDGE::blocker, dlist_iter::cur, dclist_count(), dclist_foreach, dlist_container, i, j, EDGE::link, links, PGPROC::lockGroupLeader, MemSet, EDGE::pred, topoProcs, EDGE::waiter, PGPROC::waitLock, and LOCK::waitProcs.
Referenced by ExpandConstraints().
|
static |
Definition at line 108 of file deadlock.c.
Referenced by InitDeadLockChecking(), and TopoSort().
|
static |
Definition at line 107 of file deadlock.c.
Referenced by InitDeadLockChecking(), and TopoSort().
|
static |
Definition at line 128 of file deadlock.c.
Referenced by DeadLockCheck(), FindLockCycleRecurseMember(), and GetBlockingAutoVacuumPgproc().
|
static |
Definition at line 116 of file deadlock.c.
Referenced by DeadLockCheckRecurse(), InitDeadLockChecking(), and TestConfiguration().
|
static |
Definition at line 124 of file deadlock.c.
Referenced by DeadLockReport(), FindLockCycleRecurseMember(), InitDeadLockChecking(), and RememberSimpleDeadLock().
|
static |
Definition at line 118 of file deadlock.c.
Referenced by DeadLockCheckRecurse(), and InitDeadLockChecking().
|
static |
Definition at line 123 of file deadlock.c.
Referenced by DeadLockCheckRecurse(), InitDeadLockChecking(), and TestConfiguration().
|
static |
Definition at line 117 of file deadlock.c.
Referenced by DeadLockCheck(), DeadLockCheckRecurse(), and TestConfiguration().
|
static |
Definition at line 125 of file deadlock.c.
Referenced by DeadLockReport(), FindLockCycle(), FindLockCycleRecurse(), and RememberSimpleDeadLock().
|
static |
Definition at line 122 of file deadlock.c.
Referenced by DeadLockCheck(), DeadLockCheckRecurse(), and TestConfiguration().
|
static |
Definition at line 103 of file deadlock.c.
Referenced by FindLockCycle(), and FindLockCycleRecurse().
|
static |
Definition at line 112 of file deadlock.c.
Referenced by DeadLockCheck(), ExpandConstraints(), and FindLockCycleRecurseMember().
|
static |
Definition at line 121 of file deadlock.c.
Referenced by DeadLockCheck(), DeadLockCheckRecurse(), InitDeadLockChecking(), and TestConfiguration().
|
static |
Definition at line 106 of file deadlock.c.
Referenced by InitDeadLockChecking(), and TopoSort().
|
static |
Definition at line 102 of file deadlock.c.
Referenced by FindLockCycleRecurse(), and InitDeadLockChecking().
|
static |
Definition at line 113 of file deadlock.c.
Referenced by ExpandConstraints(), and InitDeadLockChecking().
|
static |
Definition at line 111 of file deadlock.c.
Referenced by DeadLockCheck(), ExpandConstraints(), FindLockCycleRecurseMember(), and InitDeadLockChecking().