Skip to content

Confusing error message: detected infinite loop #2451

@ajeetdsouza

Description

@ajeetdsouza

Hi, thanks for maintaining pgx! I was testing some Go code that was reliant on pgxpool with Antithesis, and ran into the following error:

pgxpool: detected infinite loop acquiring connection; likely bug in PrepareConn or BeforeAcquire hook

This was confusing, because I hadn't set a PrepareConn / BeforeAcquire hook, but I went through the code and found this:

pgx/pgxpool/pool.go

Lines 630 to 634 in 4c1308c

err := cr.conn.Ping(pingCtx)
if err != nil {
res.Destroy()
continue
}

It seems that in the event of a network error, if all pings to Postgres fail, pgxpool throws a detected infinite loop error. Could the error message here be improved somehow - and would it be possible to use a sentinel error that can be caught and handled?

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