Skip to content

how to understand what kind of error returned by Query #2587

Open

Description

@vtolstov

Hi!, i'm using pgx with yandex ha-sql library and create something like automatic retry for failed statements (internally all my queries are idempotent).
But for some reasons error may not mean network error, or postgresql server error like conflict with recovery.

So does it possible to understand what error belongs to group and retry only needed group of errors (not i have ugly thing like check for context errors and some network errors)

Activity

  1. jackc commented on Jun 29, 2026

    @jackc
    Owner

    So does it possible to understand what error belongs to group and retry only needed group of errors (not i have ugly thing like check for context errors and some network errors)

    The closest thing pgx has is pgconn.SafeToRetry. But that is stricter than you need. Since pgx doesn't know if your query was read only or not it only considers an error safe to retry if it is sure the server did not receive it.

    But beyond that I think you would need to specify which error categories are acceptable to retry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions