ACTIVITY
Timeline
Timeline for the post: PostgreSQL replica apply stalls 'waiting for lock' during bursts of DDL on primary
Currently licensed under: CC BY-SA 4.0
| When | What | By | License | Comment |
|---|---|---|---|---|
Oct 22, 2026, 9:30:52 AM 1mo ago | Answer | simonsupport | CC BY-SA 4.0 | The most practical fix is to avoid long-running read queries on the standby during windows you run exclusive DDL on the primary. Start by listing long-running sessions on the replica (pg_stat_activity) and add a short statement_timeout for ad-hoc reporting or schedule heavy reports after DDL windows. If you must run queries, switch DDL to online methods (CREATE INDEX CONCURRENTLY, add nullable columns then backfill) so WAL apply doesn't need ACCESS EXCLUSIVE. As a shorter-term mitigation, enable hot_standby_feedback on the replica to avoid query cancellations on the primary — but monitor primary bloat and autovacuum. Verify by running a small DDL while no long queries exist and confirm WAL applies without lag. Rollback by disabling hot_standby_feedback or restoring timeouts if it causes bloat. |
Oct 22, 2026, 9:30:52 AM 1mo ago | Solution accepted | erikethernet | An answer was marked as the accepted solution. | |
Oct 22, 2026, 9:30:52 AM 1mo ago | Created | erikethernet | CC BY-SA 4.0 | PostgreSQL replica apply stalls 'waiting for lock' during bursts of DDL on primary |