SandboxCase.Sandbox.DeadlockDetector (sandbox_case v0.3.12)

Copy Markdown View Source

On-demand Postgres lock chain reporter.

Attaches to [:db_connection, :connection_error] telemetry. When a connection checkout fails (typically a timeout), immediately queries pg_stat_activity and pg_locks to show which queries are blocked and which are holding the locks.

Only works with Postgres repos.

Configuration

config :sandbox_case,
  sandbox: [
    ecto: true,
    deadlock_detector: true
  ]

Or with an explicit repo:

deadlock_detector: [repo: MyApp.Repo]

Summary

Functions

Query Postgres for blocked queries right now. Can be called manually.

Functions

check_for_locks(repo)

Query Postgres for blocked queries right now. Can be called manually.