Skip to content

Commit

Permalink
Ensure there is a timeout for background pool connections
Browse files Browse the repository at this point in the history
  • Loading branch information
jackc committed Aug 6, 2022
1 parent f3e04b2 commit 7ce634d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pgxpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
// see https://github.com/jackc/pgx/issues/1259
ctx = detachedCtx{ctx}

// But we do want to ensure that a connect won't hang forever.
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
defer cancel()

connConfig := p.config.ConnConfig

if p.beforeConnect != nil {
Expand Down

0 comments on commit 7ce634d

Please sign in to comment.