SQLSTATE 55P03 ERROR Class 55: Object Not In Prerequisite State

lock_not_available Lock Not Available — SQLSTATE 55P03

A requested lock could not be obtained (NOWAIT or lock_timeout).

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Symptoms

A requested lock could not be obtained (NOWAIT or lock_timeout).

  • The error is written to the server log and returned to the client carrying SQLSTATE 55P03.
  • Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.
  • PL/pgSQL can trap it by name: EXCEPTION WHEN lock_not_available THEN.

Environment

Severity: ERROR  |  PostgreSQL versions: 12, 13, 14, 15, 16, 17

Reproduce with the exact statement and read the full message in the server log (raise log_min_messages / set log_min_error_statement for more context).

Root Cause

The statement used NOWAIT or hit lock_timeout while another session held the lock.

Diagnostic Queries

Recovery

Steps to resolve 55P03:

  1. Retry with backoff; reduce contention and shorten transactions.
  2. Identify the blocker: SELECT * FROM pg_locks JOIN pg_stat_activity USING (pid) WHERE NOT granted;.
  3. For DDL, set a short lock_timeout and retry so you do not build a long blocking queue.

Reference: PostgreSQL error codes — Class 55 (Object Not In Prerequisite State).

Was this helpful?