Hi, On 2018-04-13 16:43:09 +0300, Konstantin Knizhnik wrote: > Updated patch is attached. > + /* > + * Ensure that only one backend is checking for deadlock. > + * Otherwise under high load cascade of deadlock timeout expirations > can cause stuck of Postgres. > + */ > + if (!pg_atomic_test_set_flag(&ProcGlobal->activeDeadlockCheck)) > + { > + enable_timeout_after(DEADLOCK_TIMEOUT, DeadlockTimeout); > + return; > + } > + inside_deadlock_check = true;
I can't see that ever being accepted. This means there's absolutely no bound for deadlock checks happening even under light concurrency, even if there's no contention for a large fraction of the time. If you want to improve this, improve the efficiency of the implementation, check multiple lockers at the same time (set a bit afterwards that they don't recheck themselves). There's plenty approaches that don't result in a significantly worse user experience. Greetings, Andres Freund