SQLSTATE 57014 ERROR Class 57: Operator Intervention

query_canceled canceling statement due to conflict with recovery — 57014

PostgreSQL error “canceling statement due to conflict with recovery — 57014” (SQLSTATE 57014): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

A query on a hot standby was cancelled because it conflicted with WAL replay from the primary. PostgreSQL raises SQLSTATE 57014 (query_canceled).

  • A read query on a replica was cancelled.
  • Recovery (WAL replay) needed to remove rows the query was reading.
  • Common on busy hot standbys.

What the server log shows

ERROR:  canceling statement due to conflict with recovery
DETAIL:  User query might have needed to see row versions that must be removed.

Why PostgreSQL raises this — what the manual says

Section 26.4.2 Handling Query Conflicts:

“Once the delay specified by max_standby_archive_delay or max_standby_streaming_delay has been exceeded, conflicting queries will be canceled.”

On a standby, WAL replay may need to clean up row versions a long-running read query still requires. To keep replay progressing, PostgreSQL cancels the conflicting query with 57014.

Common causes

  • Long-running queries on a hot standby.
  • Aggressive vacuum/cleanup on the primary.
  • Low max_standby_streaming_delay.

Relevant GUC parameters

Parameter Default Effect
max_standby_streaming_delay 30s How long replay waits for conflicting queries before cancelling them.
hot_standby_feedback off When on, reduces conflicts by informing the primary of standby queries.

How to fix it

  1. Enable hot_standby_feedback = on to reduce cleanup conflicts.
  2. Increase max_standby_streaming_delay to give queries more time.
  3. Retry the query, or run long analytics against a dedicated replica.

Related & next steps

Reference: PostgreSQL 18 Section 27.4 “Hot Standby”.

Was this helpful?