aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/deadlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/lmgr/deadlock.c')
-rw-r--r--src/backend/storage/lmgr/deadlock.c99
1 files changed, 47 insertions, 52 deletions
diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c
index 7edabff6dd4..06de6071f14 100644
--- a/src/backend/storage/lmgr/deadlock.c
+++ b/src/backend/storage/lmgr/deadlock.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.34 2005/04/29 22:28:24 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.35 2005/10/15 02:49:26 momjian Exp $
*
* Interface:
*
@@ -130,15 +130,15 @@ InitDeadLockChecking(void)
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
/*
- * FindLockCycle needs at most MaxBackends entries in visitedProcs[]
- * and deadlockDetails[].
+ * FindLockCycle needs at most MaxBackends entries in visitedProcs[] and
+ * deadlockDetails[].
*/
visitedProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *));
deadlockDetails = (DEADLOCK_INFO *) palloc(MaxBackends * sizeof(DEADLOCK_INFO));
/*
- * TopoSort needs to consider at most MaxBackends wait-queue entries,
- * and it needn't run concurrently with FindLockCycle.
+ * TopoSort needs to consider at most MaxBackends wait-queue entries, and
+ * it needn't run concurrently with FindLockCycle.
*/
topoProcs = visitedProcs; /* re-use this space */
beforeConstraints = (int *) palloc(MaxBackends * sizeof(int));
@@ -146,33 +146,32 @@ InitDeadLockChecking(void)
/*
* We need to consider rearranging at most MaxBackends/2 wait queues
- * (since it takes at least two waiters in a queue to create a soft
- * edge), and the expanded form of the wait queues can't involve more
- * than MaxBackends total waiters.
+ * (since it takes at least two waiters in a queue to create a soft edge),
+ * and the expanded form of the wait queues can't involve more than
+ * MaxBackends total waiters.
*/
waitOrders = (WAIT_ORDER *)
palloc((MaxBackends / 2) * sizeof(WAIT_ORDER));
waitOrderProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *));
/*
- * Allow at most MaxBackends distinct constraints in a configuration.
- * (Is this enough? In practice it seems it should be, but I don't
- * quite see how to prove it. If we run out, we might fail to find a
- * workable wait queue rearrangement even though one exists.) NOTE
- * that this number limits the maximum recursion depth of
- * DeadLockCheckRecurse. Making it really big might potentially allow
- * a stack-overflow problem.
+ * Allow at most MaxBackends distinct constraints in a configuration. (Is
+ * this enough? In practice it seems it should be, but I don't quite see
+ * how to prove it. If we run out, we might fail to find a workable wait
+ * queue rearrangement even though one exists.) NOTE that this number
+ * limits the maximum recursion depth of DeadLockCheckRecurse. Making it
+ * really big might potentially allow a stack-overflow problem.
*/
maxCurConstraints = MaxBackends;
curConstraints = (EDGE *) palloc(maxCurConstraints * sizeof(EDGE));
/*
* Allow up to 3*MaxBackends constraints to be saved without having to
- * re-run TestConfiguration. (This is probably more than enough, but
- * we can survive if we run low on space by doing excess runs of
- * TestConfiguration to re-compute constraint lists each time needed.)
- * The last MaxBackends entries in possibleConstraints[] are reserved
- * as output workspace for FindLockCycle.
+ * re-run TestConfiguration. (This is probably more than enough, but we
+ * can survive if we run low on space by doing excess runs of
+ * TestConfiguration to re-compute constraint lists each time needed.) The
+ * last MaxBackends entries in possibleConstraints[] are reserved as
+ * output workspace for FindLockCycle.
*/
maxPossibleConstraints = MaxBackends * 4;
possibleConstraints =
@@ -361,9 +360,9 @@ TestConfiguration(PGPROC *startProc)
return -1;
/*
- * Check for cycles involving startProc or any of the procs mentioned
- * in constraints. We check startProc last because if it has a soft
- * cycle still to be dealt with, we want to deal with that first.
+ * Check for cycles involving startProc or any of the procs mentioned in
+ * constraints. We check startProc last because if it has a soft cycle
+ * still to be dealt with, we want to deal with that first.
*/
for (i = 0; i < nCurConstraints; i++)
{
@@ -447,8 +446,8 @@ FindLockCycleRecurse(PGPROC *checkProc,
if (i == 0)
{
/*
- * record total length of cycle --- outer levels will now
- * fill deadlockDetails[]
+ * record total length of cycle --- outer levels will now fill
+ * deadlockDetails[]
*/
Assert(depth <= MaxBackends);
nDeadlockDetails = depth;
@@ -457,8 +456,8 @@ FindLockCycleRecurse(PGPROC *checkProc,
}
/*
- * Otherwise, we have a cycle but it does not include the
- * start point, so say "no deadlock".
+ * Otherwise, we have a cycle but it does not include the start
+ * point, so say "no deadlock".
*/
return false;
}
@@ -480,8 +479,8 @@ FindLockCycleRecurse(PGPROC *checkProc,
conflictMask = lockMethodTable->conflictTab[checkProc->waitLockMode];
/*
- * Scan for procs that already hold conflicting locks. These are
- * "hard" edges in the waits-for graph.
+ * Scan for procs that already hold conflicting locks. These are "hard"
+ * edges in the waits-for graph.
*/
procLocks = &(lock->procLocks);
@@ -520,15 +519,14 @@ FindLockCycleRecurse(PGPROC *checkProc,
}
proclock = (PROCLOCK *) SHMQueueNext(procLocks, &proclock->lockLink,
- offsetof(PROCLOCK, lockLink));
+ offsetof(PROCLOCK, lockLink));
}
/*
* Scan for procs that are ahead of this one in the lock's wait queue.
- * Those that have conflicting requests soft-block this one. This
- * must be done after the hard-block search, since if another proc
- * both hard- and soft-blocks this one, we want to call it a hard
- * edge.
+ * Those that have conflicting requests soft-block this one. This must be
+ * done after the hard-block search, since if another proc both hard- and
+ * soft-blocks this one, we want to call it a hard edge.
*
* If there is a proposed re-ordering of the lock's wait order, use that
* rather than the current wait order.
@@ -569,8 +567,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
info->pid = checkProc->pid;
/*
- * Add this edge to the list of soft edges in the
- * cycle
+ * Add this edge to the list of soft edges in the cycle
*/
Assert(*nSoftEdges < MaxBackends);
softEdges[*nSoftEdges].waiter = checkProc;
@@ -610,8 +607,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
info->pid = checkProc->pid;
/*
- * Add this edge to the list of soft edges in the
- * cycle
+ * Add this edge to the list of soft edges in the cycle
*/
Assert(*nSoftEdges < MaxBackends);
softEdges[*nSoftEdges].waiter = checkProc;
@@ -655,8 +651,8 @@ ExpandConstraints(EDGE *constraints,
/*
* Scan constraint list backwards. This is because the last-added
- * constraint is the only one that could fail, and so we want to test
- * it for inconsistency first.
+ * constraint is the only one that could fail, and so we want to test it
+ * for inconsistency first.
*/
for (i = nConstraints; --i >= 0;)
{
@@ -679,8 +675,8 @@ ExpandConstraints(EDGE *constraints,
Assert(nWaitOrderProcs <= MaxBackends);
/*
- * Do the topo sort. TopoSort need not examine constraints after
- * this one, since they must be for different locks.
+ * Do the topo sort. TopoSort need not examine constraints after this
+ * one, since they must be for different locks.
*/
if (!TopoSort(lock, constraints, i + 1,
waitOrders[nWaitOrders].procs))
@@ -739,15 +735,14 @@ TopoSort(LOCK *lock,
}
/*
- * Scan the constraints, and for each proc in the array, generate a
- * count of the number of constraints that say it must be before
- * something else, plus a list of the constraints that say it must be
- * after something else. The count for the j'th proc is stored in
- * beforeConstraints[j], and the head of its list in
- * afterConstraints[j]. Each constraint stores its list link in
- * constraints[i].link (note any constraint will be in just one list).
- * The array index for the before-proc of the i'th constraint is
- * remembered in constraints[i].pred.
+ * Scan the constraints, and for each proc in the array, generate a count
+ * of the number of constraints that say it must be before something else,
+ * plus a list of the constraints that say it must be after something
+ * else. The count for the j'th proc is stored in beforeConstraints[j],
+ * and the head of its list in afterConstraints[j]. Each constraint
+ * stores its list link in constraints[i].link (note any constraint will
+ * be in just one list). The array index for the before-proc of the i'th
+ * constraint is remembered in constraints[i].pred.
*/
MemSet(beforeConstraints, 0, queue_size * sizeof(int));
MemSet(afterConstraints, 0, queue_size * sizeof(int));
@@ -933,7 +928,7 @@ DeadLockReport(void)
DescribeLockTag(&buf2, &info->locktag);
appendStringInfo(&buf,
- _("Process %d waits for %s on %s; blocked by process %d."),
+ _("Process %d waits for %s on %s; blocked by process %d."),
info->pid,
GetLockmodeName(info->lockmode),
buf2.data,