Thread: Deadlock detection

Deadlock detection

From
Alvaro Herrera
Date:
Hackers,

I've been briefly looking at the deadlock detection code to see what's
needed to support nested transactions.

It seems the only way to run the deadlock detection
(storage/lmgr/deadlock.c:DeadLockCheck()) is through
storage/lmgr/proc.c:CheckDeadLock(), and it's only called with MyProc as
argument.  AFAIU this means that the only transaction that can be
aborted is the transaction that's trying to acquire the lock.

If this is so, then it's obvious that there can't be subtransactions in
progress of the transaction that's going to be aborted.  This means that
there's no need for a mechanism to abort a transaction and all its
subtransactions, because they are all finished if there are any at all.

Am I right on this?

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El dia que dejes de cambiar dejaras de vivir"


Re: Deadlock detection

From
Tom Lane
Date:
Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
> AFAIU this means that the only transaction that can be
> aborted is the transaction that's trying to acquire the lock.

Correct.  There's no need to treat this error as any different from any
other error.
        regards, tom lane