E9
Taking dangerous lock without timeout
Description
Triggered when: A lock that would block many common operations was taken without a timeout.
Effect: This can block all other operations on the table indefinitely if any other transaction holds a conflicting lock while idle in transaction
or active
.
Workaround: Run SET LOCAL lock_timeout = '2s';
before the statement and retry the migration if necessary.
Detected by: eugene lint
and eugene trace
Problematic migration
-- 1.sql
create table authors (
id integer generated always as identity
primary key,
name text not null
);
-- 2.sql
alter table authors add column email text;
Safer migration
-- 1.sql
create table authors (
id integer generated always as identity
primary key,
name text not null
);
-- 2.sql
set local lock_timeout = '2s';
alter table authors add column email text;