SELECT * FROM pg_catalog.pg_locks l JOIN pg_catalog.pg_stat_activity a ON l.pid = a.pid WHERE NOT GRANTED;
This will help identify which queries are waiting for locks, potentially leading to a deadlock.SELECT pid, age(clock_timestamp(), query_start), usename, query FROM pg_stat_activity WHERE state != 'idle' AND query NOT ILIKE '%pg_stat_activity%' ORDER BY query_start desc;
This will show you any long-running queries that might need to be terminated to resolve the deadlock.SELECT pg_cancel_backend(pid);
or SELECT pg_terminate_backend(pid);
replacing pid
with the process ID of the query to be canceled or terminated.SELECT * FROM pg_locks WHERE NOT granted;
This will show you if there are any remaining locks that were not automatically released.Let Dr. Droid create custom investigation plans for your infrastructure.
Start Free POC (15-min setup) →