Skip to content

Commit 7ce634d

Browse files
committed
Ensure there is a timeout for background pool connections
1 parent f3e04b2 commit 7ce634d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pgxpool/pool.go

+4
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
214214
// see https://github.com/jackc/pgx/issues/1259
215215
ctx = detachedCtx{ctx}
216216

217+
// But we do want to ensure that a connect won't hang forever.
218+
ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)
219+
defer cancel()
220+
217221
connConfig := p.config.ConnConfig
218222

219223
if p.beforeConnect != nil {

0 commit comments

Comments
 (0)