SandboxCase.Sandbox.LockMonitor (sandbox_case v0.4.0-rc1)

Copy Markdown View Source

Background monitor that periodically polls Postgres for blocked queries and reports the lock chain.

Catches lock contention between async tests as it happens, instead of waiting for the ownership timeout (15-120s).

Configuration

config :sandbox_case,
  sandbox: [
    lock_monitor: true
    # or with options:
    lock_monitor: [interval: 2_000, repo: MyApp.Repo]
  ]

What it reports

When a query is blocked waiting for a lock, the monitor logs:

  • The blocked query and how long it's been waiting
  • The blocking query and its state
  • Both Postgres PIDs for further investigation

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)