SQL · correctness
require-lock-timeout
sql:require-lock-timeout DDL migration missing positive SET [LOCAL] lock_timeout or statement_timeout prior to DDL.
- Code
- SARJ110
- Default
- error
- Fix
- none
- Languages
- sql
Why
Unbounded lock waits can stall production traffic indefinitely when migration DDL contends with active transactions.
Fix
Set a short positive lock_timeout or statement_timeout before the DDL statement.
Before / after
Executed by this rule’s unit tests.
Before
DDL without a positive timeout
ALTER TABLE users ADD COLUMN note TEXT;
After
DDL preceded by a positive lock timeout
SET lock_timeout = '3s';
ALTER TABLE users ADD COLUMN note TEXT;
Limits
- Only PostgreSQL migration paths and explicitly marked PostgreSQL migrations are checked.