Postgres lock bug from unclean shutdown took down entire Next.js site
A developer's Next.js site began returning HTTP 500 errors on every request after a Postgres lock conflict caused the background worker to fail on boot. The root cause was a leftover lock on the pgboss.queue table from a previous unclean database shutdown, triggering error code 55P03 (lock_not_available) each time the worker tried to initialize. Because the worker was booted inside the web process via Next.js's instrumentation hook, its failure brought down the entire site rather than degrading gracefully. The fix involved catching worker boot errors so the web server stays up regardless, and adding a retry loop with exponential backoff so the worker self-heals once the lock clears. A secondary bug was also identified where the 'started' flag was set before a successful boot, permanently blocking any retries after a failure.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in