Coordinate work with advisory locks
Advisory locks let application code claim a named lock so only one worker runs a job at a time. pg_try_advisory_lock returns false to the second worker and true again once the first releases it.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
Sometimes you need mutual exclusion that PostgreSQL's row/table locks do not express, 'only one instance of this cron job runs at once'. Advisory locks are application-defined locks on an arbitrary key, enforced by the database.
Meridian runs a scheduled reconciliation on several app nodes, but only one should execute at a time. Each node tries to take advisory lock 4820; only one wins.
Simple terms
Sometimes you need "only one copy of this job runs at a time", which is not something row or table locks can express. Advisory locks let your application pick an arbitrary number as a named lock and have PostgreSQL enforce it. Each worker calls pg_try_advisory_lock on the same key; the first gets true and runs, the rest get false and step aside, until the winner releases it.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other Locking & concurrency runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Fixes these errors
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.