require-lock-timeout
Set lock_timeout before taking strong locks.
Severity: warning · Lock: ACCESS EXCLUSIVE
Even an instant ALTER TABLE has to wait for its lock. While it waits behind a long-running query, every new query on the table queues behind the ALTER, and the table looks down for as long as the slowest query runs.
Instead of
Section titled “Instead of”ALTER TABLE users ADD COLUMN nickname text;SET lock_timeout = '2s';ALTER TABLE users ADD COLUMN nickname text;If the lock isn’t free within the timeout, the migration fails fast and can be retried. pgdeadbolt reports this once per file, at the first statement that needs a strong lock.
To skip this rule for one statement, put -- pgdeadbolt-ignore require-lock-timeout on the line above it.