FreeNo sign-up.

PostgreSQL Deadlock Analyzer

Paste a PostgreSQL deadlock detected entry from the server log. dbCove AI shows who waited for whom, why the cycle formed and the change that stops it.

How to get the deadlock

From the server log

Paste from ERROR: deadlock detected through the DETAIL, HINT, CONTEXT and STATEMENT lines.

The waits before it

Log every lock wait longer than deadlock_timeout, so the log shows how the cycle built up:

ALTER SYSTEM SET log_lock_waits = on; SELECT pg_reload_conf();
How many so far

Deadlocks since the statistics were reset, by database:

SELECT datname, deadlocks FROM pg_stat_database;

What it looks for in a PostgreSQL deadlock

ShareLock on transaction

A row lock: each session waits for a row the other already changed.

Lock order

Transfers and batch updates that touch the same rows in opposite order.

Foreign keys

Key share locks from inserts into a child table meeting updates of the parent row.

Explicit locks

LOCK TABLE and advisory locks taken in different order.

The victim

Which process got the error, and the statement it ran.

This was one deadlock. dbCove catches every one.

On your own databases dbCove records every deadlock with the statements on both sides, groups them by pattern, and its AI explains them as they happen. Free for 2 databases of each engine.

Questions

Is what I paste kept?

It is sent to our AI provider to be explained and kept by us for up to 12 months to improve the tools; the AI provider does not keep it or train on it. Remove passwords and personal data before you paste.

Which process is the victim?

The one that reports ERROR: deadlock detected. PostgreSQL aborts its transaction and the other process goes on.

Is raising deadlock_timeout a fix?

No. deadlock_timeout only sets how long a lock wait lasts before the check runs. The cycle is in the order the transactions take their locks, and the answer gives the change that breaks it.

Which versions does it read?

PostgreSQL 10 and later, including Amazon RDS, Aurora PostgreSQL, Azure Database for PostgreSQL and Cloud SQL.