MP110WARNINGFreeNeeds --database-url

warn-partitioned-parent-fanout

What It Detects

DDL on a partitioned parent takes the lock on the parent and on every partition.

Why It's Dangerous

DDL on a partitioned table recurses: PostgreSQL locks the parent and every partition, and holds all of those locks until the statement commits. The blocking window is therefore set by the slowest partition, not by the statement, and a lock_timeout only helps if it fires before the queue behind the parent lock has stalled everything else. The lock count scales with the partition count too, so on a table with a partition per day and a couple of years of history a single ALTER can exhaust max_locks_per_transaction and fail outright.

Bad Example

-- events is partitioned by day, 365 partitions live
ALTER TABLE events ADD COLUMN note text;

Good Example

-- Confirm the fan-out and that the lock table can hold it before
-- writing the DDL:
SELECT count(*) AS partitions FROM pg_inherits WHERE inhparent = 'events'::regclass;
SHOW max_locks_per_transaction;

Configuration

Disable this rule:

# .migrationpilotrc.yml
rules:
  MP110: false

Or change its severity:

# .migrationpilotrc.yml
rules:
  MP110:
    severity: warning