SQLSTATE 57014Severity lowLab verified

Incident brief

Query canceled

A statement ran longer than the configured statement_timeout, and PostgreSQL canceled it. This is PostgreSQL enforcing a time limit you set, not a crash.

Reproduced on PostgreSQL 16.14Verified 2026-07-16 (Docker lab, PostgreSQL 16.14)Reviewed by Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What
Query canceled
What triggers it
SET statement_timeout to a short value, such as 500ms.
The fix
Raise statement_timeout for this specific query if it's genuinely expected to take longer.
Proof
Reproduced on PostgreSQL 16.14 → A 2-second query, run under a 500ms statement_timeout, was canceled with SQLSTATE 57014. The session was unaffected afterward.

The fix

What to do right now

The immediate, application-level response to this error.

  • Raise statement_timeout for this specific query if it's genuinely expected to take longer.
  • If the query is meant to be fast, treat the timeout as a signal to investigate the query, not just to retry it — see the counterexample.
  • Retrying the exact same slow query with the exact same timeout will simply time out again.
Fix — SQL
SET statement_timeout = '3s';
SELECT pg_sleep(2);
RESET statement_timeout;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 16.14
Last verified
2026-07-16 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed