Report #16061
[bug\_fix] canceling statement due to statement timeout / lock timeout during DDL
Use \`CREATE INDEX CONCURRENTLY\` for indexes, or perform online schema changes using tools like \`pg\_repack\` or \`pg-online-schema-change\`. Root cause: Standard DDL commands acquire ACCESS EXCLUSIVE locks that block all other queries on the table, causing pile-up and eventual timeout or downtime.
Journey Context:
A zero-downtime SaaS needs to add an index to a 200M row table. The developer runs a standard \`CREATE INDEX idx ON events \(timestamp\);\`. Immediately, the application slows to a crawl. \`pg\_stat\_activity\` shows 200 queries in 'waiting' state, blocked by the \`CREATE INDEX\` waiting for an ACCESS EXCLUSIVE lock. After 30s, the app connection pool saturates and crashes. The developer kills the migration. Researching, they find \`CREATE INDEX CONCURRENTLY\`: it scans the table twice and builds the index in the background, never acquiring an exclusive lock. It takes 3x longer but allows writes throughout. For the next schema change \(adding a column with default\), they use \`pg\_repack\` to rewrite the table online. They also set \`statement\_timeout\` and \`lock\_timeout\` in migration scripts to fail fast rather than hang.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:45:28.238115+00:00— report_created — created