82 EDGE *softEdges,
int *nSoftEdges);
84 EDGE *softEdges,
int *nSoftEdges);
87 int depth,
EDGE *softEdges,
int *nSoftEdges);
93 static void PrintLockQueue(
LOCK *lock,
const char *info);
236 TRACE_POSTGRESQL_DEADLOCK_FOUND();
240 elog(
FATAL,
"deadlock seems to have disappeared");
255 #ifdef DEBUG_DEADLOCK
256 PrintLockQueue(lock,
"DeadLockCheck:");
261 for (
int j = 0;
j < nProcs;
j++)
264 #ifdef DEBUG_DEADLOCK
265 PrintLockQueue(lock,
"rearranged to:");
312 int oldPossibleConstraints;
339 for (
i = 0;
i < nEdges;
i++)
341 if (!savedList &&
i > 0)
345 elog(
FATAL,
"inconsistent results during deadlock check");
406 softFound = nSoftEdges;
412 softFound = nSoftEdges;
419 softFound = nSoftEdges;
523 memberProc != checkProc &&
573 if (leader != checkProcLeader)
575 for (lm = 1; lm <= numLockModes; lm++)
582 softEdges, nSoftEdges))
589 info->
pid = checkProc->
pid;
616 if (checkProc ==
MyProc &&
648 for (
i = 0;
i < queue_size;
i++)
663 if (leader == checkProcLeader)
671 softEdges, nSoftEdges))
678 info->
pid = checkProc->
pid;
684 softEdges[*nSoftEdges].
waiter = checkProcLeader;
685 softEdges[*nSoftEdges].
blocker = leader;
686 softEdges[*nSoftEdges].
lock = lock;
695 PGPROC *lastGroupMember = NULL;
710 lastGroupMember = checkProc;
718 lastGroupMember = proc;
720 Assert(lastGroupMember != NULL);
736 if (proc == lastGroupMember)
741 leader != checkProcLeader)
745 softEdges, nSoftEdges))
752 info->
pid = checkProc->
pid;
758 softEdges[*nSoftEdges].
waiter = checkProcLeader;
759 softEdges[*nSoftEdges].
blocker = leader;
760 softEdges[*nSoftEdges].
lock = lock;
790 int nWaitOrderProcs = 0;
801 for (
i = nConstraints; --
i >= 0;)
906 for (
i = 0;
i < nConstraints;
i++)
925 for (
j = queue_size; --
j >= 0;)
954 for (k = queue_size; --k >= 0;)
978 constraints[
i].
pred = jj;
994 last = queue_size - 1;
995 for (
i = queue_size - 1;
i >= 0;)
1003 for (
j = last;
j >= 0;
j--)
1026 for (
c = 0;
c <= last; ++
c)
1048 #ifdef DEBUG_DEADLOCK
1050 PrintLockQueue(
LOCK *lock,
const char *info)
1055 printf(
"%s lock %p queue ", info, lock);
1091 nextpid = info[1].
pid;
1104 _(
"Process %d waits for %s on %s; blocked by process %d."),
1123 _(
"Process %d: %s"),
1132 errmsg(
"deadlock detected"),
1135 errhint(
"See server log for query details.")));
const char * pgstat_get_backend_current_activity(int pid, bool checkUser)
#define Assert(condition)
#define MemSet(start, val, len)
static bool TopoSort(LOCK *lock, EDGE *constraints, int nConstraints, PGPROC **ordering)
static int TestConfiguration(PGPROC *startProc)
static WAIT_ORDER * waitOrders
static bool FindLockCycleRecurseMember(PGPROC *checkProc, PGPROC *checkProcLeader, int depth, EDGE *softEdges, int *nSoftEdges)
static bool FindLockCycle(PGPROC *checkProc, EDGE *softEdges, int *nSoftEdges)
static int maxPossibleConstraints
static bool DeadLockCheckRecurse(PGPROC *proc)
PGPROC * GetBlockingAutoVacuumPgproc(void)
static EDGE * possibleConstraints
static PGPROC ** waitOrderProcs
void RememberSimpleDeadLock(PGPROC *proc1, LOCKMODE lockmode, LOCK *lock, PGPROC *proc2)
static PGPROC ** visitedProcs
static bool ExpandConstraints(EDGE *constraints, int nConstraints)
static int * beforeConstraints
static int nDeadlockDetails
void DeadLockReport(void)
static int * afterConstraints
static DEADLOCK_INFO * deadlockDetails
static int maxCurConstraints
void InitDeadLockChecking(void)
static int nCurConstraints
DeadLockState DeadLockCheck(PGPROC *proc)
static PGPROC * blocking_autovacuum_proc
static EDGE * curConstraints
static int nPossibleConstraints
static bool FindLockCycleRecurse(PGPROC *checkProc, int depth, EDGE *softEdges, int *nSoftEdges)
static PGPROC ** topoProcs
int errdetail_internal(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errdetail_log(const char *fmt,...)
#define ereport(elevel,...)
#define dlist_foreach(iter, lhead)
static void dclist_push_tail(dclist_head *head, dlist_node *node)
static uint32 dclist_count(const dclist_head *head)
static void dclist_init(dclist_head *head)
#define dlist_container(type, membername, ptr)
#define dclist_foreach(iter, lhead)
static void const char fflush(stdout)
void DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
const char * GetLockmodeName(LOCKMETHODID lockmethodid, LOCKMODE mode)
LockMethod GetLocksMethodTable(const LOCK *lock)
#define LOCK_LOCKTAG(lock)
@ LOCKTAG_RELATION_EXTEND
@ DS_BLOCKED_BY_AUTOVACUUM
#define LOCKBIT_ON(lockmode)
MemoryContext TopMemoryContext
#define ERRCODE_T_R_DEADLOCK_DETECTED
void pgstat_report_deadlock(void)
#define PROC_IS_AUTOVACUUM
MemoryContextSwitchTo(old_ctx)
void ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
uint8 locktag_lockmethodid
const LOCKMASK * conflictTab
dlist_head lockGroupMembers
static struct link * links