Transaction & Policy Checks

Beyond DDL, pgfence enforces operational best practices that prevent silent production incidents.

Transaction Checks

#PatternSeverity
25NOT VALID + VALIDATE CONSTRAINT in the same transactionerror
26Multiple ACCESS EXCLUSIVE statements compoundingwarning
27CREATE INDEX CONCURRENTLY inside a transactionerror
28Bulk UPDATE without WHERE in migrationwarning
29Wide lock window: ACCESS EXCLUSIVE on multiple tables in same transactionwarning

Policy Checks

  • Missing SET lock_timeout: prevents lock queue death spirals
  • Missing SET statement_timeout: forces the server to abort statements that run past the threshold instead of holding locks indefinitely
  • Missing SET application_name: enables pg_stat_activity visibility
  • Missing SET idle_in_transaction_session_timeout: prevents orphaned locks
  • lock_timeout set after dangerous DDL: ordering violation, timeout must be set before any statement that acquires a dangerous lock
  • lock_timeout / statement_timeout value exceeds threshold: warns when timeout values are too permissive (defaults: lock_timeout > 5s, statement_timeout > 10min)

Inline Ignore

Suppress a specific check on a statement with a comment directive:

sql
-- pgfence-ignore: add-column-not-null-no-default
ALTER TABLE users ADD COLUMN status TEXT NOT NULL;

-- pgfence-ignore
DROP TABLE legacy_sessions;  -- suppress all checks

See Configuration → Inline Ignore for the full syntax reference, including a reason and an expiry date on each ignore and -- pgfence-ignore-file for a whole file.

Rule reference

Every finding links here by rule id. There are 15 rules on this page.

RuleTitleDescription
concurrent-in-transaction CONCURRENTLY inside a transaction CREATE INDEX CONCURRENTLY and similar commands fail inside a transaction block. Run them outside a transaction.
lock-timeout-after-dangerous-statement lock_timeout set after a dangerous statement The timeout must be set before any statement that acquires a dangerous lock, or it does not protect that statement.
lock-timeout-too-long lock_timeout above the configured maximum A long lock_timeout lets a blocked migration hold up every query queued behind it.
lock-timeout-zero lock_timeout set to 0 A lock_timeout of 0 disables the timeout.
missing-application-name Missing SET application_name Setting application_name makes migration sessions identifiable in pg_stat_activity.
missing-idle-timeout Missing SET idle_in_transaction_session_timeout Without it, a stalled migration session can hold locks indefinitely.
missing-lock-timeout Missing SET lock_timeout Without a lock_timeout a migration can queue behind a long transaction and block all traffic to the table behind it.
missing-statement-timeout Missing SET statement_timeout Without a statement_timeout a long operation can hold its locks indefinitely.
non-transactional-in-transaction Command that cannot run inside a transaction VACUUM, ALTER SYSTEM, CREATE or DROP DATABASE and TABLESPACE, database-wide CLUSTER and REINDEX SCHEMA, DATABASE or SYSTEM fail inside a transaction block. Run them outside the migration transaction.
not-valid-validate-same-tx NOT VALID and VALIDATE CONSTRAINT in one transaction Validating in the same transaction that added the constraint keeps the strong lock for the whole scan and defeats the purpose of NOT VALID.
statement-after-access-exclusive Statement after ACCESS EXCLUSIVE in the same transaction Every further statement in the transaction runs while the ACCESS EXCLUSIVE lock is still held, which lengthens the window in which reads and writes are blocked.
statement-timeout-too-long statement_timeout above the configured maximum A long statement_timeout lets a runaway statement hold its locks for a long time.
unclosed-transaction Transaction left open A BEGIN without a matching COMMIT or ROLLBACK leaves the transaction open at the end of the migration file.
update-in-migration Bulk UPDATE in a migration A large UPDATE holds row locks for the whole transaction. Backfill out of band, in batches.
wide-lock-window ACCESS EXCLUSIVE locks on several tables in one transaction Locks are held until commit, so every table locked earlier stays blocked while later statements run.