postgresql

postgres deadlock_timeout - how does it work exactly


Here is my understanding of how deadlock_timeout behaves in postgres - am I correct?


Solution

  • That is mostly correct. The timer for the deadlock check is set only once. If there is no deadlock after deadlock_timeout, there will be no more check for deadlocks. That is correct, because the only way that we could get into a deadlock later on is if another backend gets stuck behind a lock as well. Then that backend's deadlock check will detect and resolve the problem.

    See the functions DeadLockCheck() and CheckDeadLock() in the source code.