Skip to main content

Errors and SQLSTATEs

Source commit cbff27b8a34e1384384018680e46c20d5c610cc9.

This reference describes SQL 0.1.1. SDKs map PostgreMQ errors into language-specific types, but the recovery decision still depends on whether an operation was rejected, an entire transaction aborted, ownership was lost, or its outcome became uncertain.

PostgreMQ error codes​

CodeMeaningTypical response
PMQ01Settlement or extension does not match a valid owned delivery.Stop treating that attempt as owned; investigate duplicate settlement or redelivery.
PMQ02Required topic or queue is missing, expired, or a queue generation no longer matches.Fix topology or replace the lost subscription deliberately.
PMQ03Invalid argument or an operation refused by its contract.Correct the caller or resolve the documented precondition.

PMQ01 on ack, nack, and release checks processing state and token. For set_vt, an expired lease also fails. Do not assume every settlement call must fail merely because the clock passed its deadline; a matching token can remain until reclaim or retirement. SDK ownership cancellation still governs application work.

PMQ02 covers publishing to a missing topic and consuming from a missing or expired queue. create_queue also rejects redeclaration of an expired Exclusive queue. Reconnecting cannot revive that subscription.

PMQ03 covers invalid names, changed queue declarations, negative attempt limits, invalid lifetimes, empty or oversized group keys, invalid timeout/batch values, mismatched parallel arrays, and destructive operations refused because referenced data remains. Check the function page for the precise conditions.

PostgreSQL errors​

CodeMeaning hereRecovery boundary
40001Serialization failure, including grouped publication or group pruning under stronger isolation.Roll back and retry the whole transaction.
40P01Deadlock, possible when transactions acquire several groups in different orders.Retry the whole transaction; use consistent group order.
55P03Manual extension encountered a row lock.Retry within the still-valid lease; do not assume extension occurred.
23503Foreign-key restriction, or a topology race during queue creation.Resolve retained references or recreate the missing prerequisite.
22004NULL array dimension, including extend_queue_keep_alive_multi(NULL, NULL).Supply non-null required arrays; use empty arrays for an empty batch.
23502NULL written to a required column.Correct input; retrying unchanged data does not help.
42501Insufficient privilege.Correct the actual role's grants or ownership.
57014Statement cancellation.Inspect transaction state and the cancellation cause.

A statement error inside an explicit transaction generally requires rollback before further ordinary work. Transaction-scoped SDK calls do not retry for the caller.

Transport failures and retries​

A lost response does not prove a statement failed. Publication or commit may have succeeded at the server. Retrying an uncertain publication can create a new message ID; use application event IDs and idempotent processing to reconcile that case.

Standalone SDK publication retries only errors establishing an aborted transaction, currently deadlock and serialization failure. Other operations have their own retry policies and ownership semantics. Do not infer that a generic “transient” network error is safe to replay for every function.

Batch outcomes are not SQL errors​

Renewal batches can return extended, busy, or omit an entry. extended carries a confirmed deadline. busy returns a NULL deadline and confirms neither ownership nor renewal; retry within the last deadline the client successfully confirmed. For visibility extension, omission means the entry did not match a live owned claim. For queue keep-alive, it means the entry did not match a live Exclusive queue with the requested generation; Durable, missing, and expired queues are also omitted. One successful SQL batch can therefore contain individual losses.

Unequal array lengths fail with PMQ03; the all-NULL keep-alive input described above raises 22004. Correlate entries by their identity and treat top-level failure separately from per-entry outcomes.

See Consumer acknowledgements, Retries, and Migration troubleshooting for task-specific responses.