Logical backups hang waiting for locks when VACUUM FULL is running on large PostgreSQL tables
Environment
PostgreSQL 13 on Debian 11. Production primary database hosts several large tables (>200GB) with occasional manual VACUUM FULL and regular logical backups using pg_dumpall run by a nightly maintenance script. autovacuum is tuned conservatively.
Symptoms
Nightly logical backups using pg_dumpall start but then hang indefinitely with the backup process shown in pg_stat_activity as 'waiting for lock'. VACUUM FULL has been scheduled by DBAs earlier in the maintenance window and appears to be running concurrently with the logical dump, causing the dump to block.
Observations
pg_stat_activity shows the dump process in a transaction waiting for a relation lock held by the VACUUM FULL backend. Server logs indicate heavy lock contention. Attempts to cancel the backup leave long-running transactions; killing VACUUM FULL releases the lock and allows the dump to proceed but causes long blocking time for other queries. The VACUUM FULL is required to reclaim large amounts of bloat but runs for many hours and requires exclusive access to tables.
Already attempted
Moved backups to later window after VACUUM FULL in a test run but operational needs require backups at night. Tested pg_basebackup as a physical backup alternative which completed without blocking, but restore requirements and offsite snapshot workflow are tied to logical dumps. Tried running VACUUM (not FULL), which did not free as much space and left bloat unresolved.
Question
How can I perform logical backups without being blocked by long VACUUM FULL operations, or how can I restructure maintenance to avoid long exclusive locks while still reclaiming bloat? Which changes are safe to try in production with low risk to data integrity?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Databases33% match
PostgreSQL 14: Rapid table bloat after nightly batch UPDATEs despite autovacuum enabled
Open0 answers - Databases31% match
PostgreSQL replica falls behind and reports WAL streaming delay when frequent autovacuum runs on primary
Open0 answers - Databases29% match
PostgreSQL logical replication slot grows until disk full after subscriber disconnects during nightly load
Open0 answers - Databases25% match
PostgreSQL logical replication falls behind after ALTER TABLE ADD COLUMN with non-null DEFAULT on large table
Open0 answers - Databases25% match
Autovacuum worker SIGSEGV after PostgreSQL 13→14 upgrade when extension is loaded via shared_preload_libraries
Open0 answers