Skip to content

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

supabase/migrations/001_users.sql · focus
ALTER TABLE users ADD COLUMN note TEXT;

After

DDL preceded by a positive lock timeout

supabase/migrations/001_users.sql · focus
SET lock_timeout = '3s';
ALTER TABLE users ADD COLUMN note TEXT;

Limits

  • Only PostgreSQL migration paths and explicitly marked PostgreSQL migrations are checked.