Diagnostic Queries
Symptoms
An autovacuum task was canceled — commonly because it conflicted with a lock request, or was interrupted. PostgreSQL reports SQLSTATE 57014 (query_canceled).
- Autovacuum on a relation was canceled.
- Often yields to a conflicting lock request (e.g. DDL).
- Repeated cancellations let bloat and XID age grow.
What the server log shows
LOG: canceling autovacuum task
CONTEXT: automatic vacuum of table "production.public.orders"
Why PostgreSQL raises this — what the manual says
Section 24.1.5 Preventing Transaction ID wraparound">Transaction ID Wraparound Failures:
“However, if the autovacuum is running to prevent transaction ID wraparound (i.e., the autovacuum query name in the pg_stat_activity view ends with (to prevent wraparound)), the autovacuum is not automatically interrupted.”
Regular autovacuum is a low-priority background task; it yields to user commands needing conflicting locks (e.g. ALTER TABLE) by canceling itself with 57014. Frequent cancellations mean tables don’t get vacuumed, allowing bloat and XID age to climb.
Common causes
- Frequent DDL or lock-heavy operations on a table preventing autovacuum from finishing.
- Manual cancellation of a vacuum.
- A busy table that autovacuum repeatedly starts and abandons.
How to fix it
- Schedule DDL during quiet windows so autovacuum can complete.
- Run a manual
VACUUMoff-peak for chronically canceled tables. - Note anti-wraparound vacuums are not auto-canceled — don’t let regular cancellations mask growing XID age.
Related & next steps
Reference: PostgreSQL 18 Section 25.1 “Routine Vacuuming”.
Thanks — noted. This helps keep the database accurate.