diff --git a/internal/datastore/crdb/pool/pool.go b/internal/datastore/crdb/pool/pool.go index 82fdd877af..a2c179357e 100644 --- a/internal/datastore/crdb/pool/pool.go +++ b/internal/datastore/crdb/pool/pool.go @@ -309,7 +309,7 @@ func (p *RetryPool) withRetries(ctx context.Context, fn func(conn *pgxpool.Conn) log.Ctx(ctx).Warn().Err(err).Uint8("retries", retries).Msg("error is not resettable or retryable") return err } - return &MaxRetryError{MaxRetries: p.maxRetries, LastErr: err} + return &MaxRetryError{MaxRetries: maxRetries, LastErr: err} } // GC marks a connection for destruction on the next Acquire. diff --git a/internal/datastore/crdb/pool/slqerrors.go b/internal/datastore/crdb/pool/slqerrors.go index ee688c9944..a5ed007ab5 100644 --- a/internal/datastore/crdb/pool/slqerrors.go +++ b/internal/datastore/crdb/pool/slqerrors.go @@ -2,7 +2,7 @@ package pool import ( "errors" - "strconv" + "fmt" "github.com/jackc/pgx/v5/pgconn" ) @@ -27,8 +27,12 @@ type MaxRetryError struct { } func (e *MaxRetryError) Error() string { - return strconv.Itoa(int(e.MaxRetries)) + "max retries reached" + ": " + e.LastErr.Error() + if e.MaxRetries == 0 { + return "retries disabled: " + e.LastErr.Error() + } + return fmt.Sprintf("max retries reached (%d): %s", e.MaxRetries, e.LastErr.Error()) } + func (e *MaxRetryError) Unwrap() error { return e.LastErr } // ResettableError is an error that we think may succeed if retried against a new connection.