Table-lock conflicts
These are table-level modes, including those with “row” in their name. A conflict means different transactions cannot hold the two modes on the same relation together. This is not a row-lock matrix or a complete prediction of queueing. See PostgreSQL's table-level locking reference.
| Key | Mode shown in a report | Conflicts with |
|---|---|---|
| AS | AccessShareLock | AX |
| RS | RowShareLock | X, AX |
| RX | RowExclusiveLock | S, SRX, X, AX |
| SUX | ShareUpdateExclusiveLock | SUX, S, SRX, X, AX |
| S | ShareLock | RX, SUX, SRX, X, AX |
| SRX | ShareRowExclusiveLock | RX, SUX, S, SRX, X, AX |
| X | ExclusiveLock | RS, RX, SUX, S, SRX, X, AX |
| AX | AccessExclusiveLock | Every mode, including AX |
Plain SELECT takes AS; ordinary inserts, updates and deletes take RX. Regular index builds take S; concurrent builds take SUX. AX conflicts even with plain reads. These modes are not a simple ladder: SUX conflicts with itself, while S does not. Locks normally last until transaction end, not just statement end. PostgreSQL locking reference.
Index builds: concurrent is not lock-free
A regular index build allows reads but blocks writes. CONCURRENTLY permits ordinary writes, but adds work, can wait for other transactions and still consumes CPU and I/O. Only one concurrent index build can run on a given table at a time. It cannot run inside a transaction block. Failed concurrent builds can leave an invalid index that requires investigation. PostgreSQL CREATE INDEX.
-- Run outside a transaction block, using your tool's non-transactional mode.
CREATE INDEX CONCURRENTLY orders_customer_idx ON orders (customer_id);
Check the migration tool's transaction behaviour before using this pattern. See Migration formats and the FRN201 rule.
Constraints: separate installation from validation
Adding a CHECK constraint with NOT VALID skips the initial scan of existing rows; it still checks subsequent inserts and updates. It does not eliminate the lock needed to install the constraint. Validation later takes SUX on the altered table. Keep the two phases in separate committed transactions if the goal is to shorten the initial lock window. PostgreSQL ALTER TABLE.
-- Phase 1: a short transaction installs the constraint.
BEGIN;
ALTER TABLE orders
ADD CONSTRAINT orders_total_nonnegative CHECK (total >= 0) NOT VALID;
COMMIT;
-- Phase 2: validate existing rows in a later transaction.
BEGIN;
ALTER TABLE orders VALIDATE CONSTRAINT orders_total_nonnegative;
COMMIT;
This assumes orders.total exists and the existing rows satisfy the check when validation runs. Ensure your migration tool does not wrap both phases in an outer transaction.
For foreign keys, installation takes SRX on both referencing and referenced tables; validation also needs RS on the referenced table. NOT VALID is available for CHECK and foreign-key constraints, not a general escape hatch for all constraints. PostgreSQL ALTER TABLE.
Waiting time and execution time are different
lock_timeout bounds each attempt to acquire a lock. It does not cap how long a lock is held after acquisition. statement_timeout bounds the statement overall, including lock waits. Set a shorter lock timeout when you want to abandon lock acquisition before the statement deadline. Choose values for your workload rather than copying the example as a production default. PostgreSQL timeout settings.
BEGIN;
SET LOCAL lock_timeout = '1s';
SET LOCAL statement_timeout = '30s';
ALTER TABLE orders ADD COLUMN note text;
COMMIT;
If a statement errors in this transaction, roll it back before retrying. SET LOCAL lasts only for the transaction; this pattern is not suitable for CREATE INDEX CONCURRENTLY, which must run outside a transaction block. Timeout settings, concurrent index restrictions.
Use the cheatsheet with a rehearsal
- Confirm the report's commit and project configuration.
- Inspect each statement's lock modes, relation names, timing and rewrite evidence.
- Compare the migration's transaction boundaries with the intended rollout.
- Review rule findings and any suppressions or approvals.
Fronelta's synthetic workload does not reproduce production concurrency. Observing no wait in rehearsal does not establish that production will have no blockers. See Understanding reports for the evidence available in a run.
This reference uses PostgreSQL 17 documentation. Check the documentation for your deployed major version and exact command variant, especially for partitioned tables and combined ALTER operations.