mirror of https://github.com/jackc/pgx.git
Add a timeout to pgxpool min connection creation
Ensure that CreateResource can't hang.pull/678/head
parent
cb1a1ebefa
commit
22ad987698
|
@ -323,7 +323,11 @@ func (p *Pool) checkIdleConnsHealth() {
|
||||||
|
|
||||||
func (p *Pool) checkMinConns() {
|
func (p *Pool) checkMinConns() {
|
||||||
for i := p.minConns - p.Stat().TotalConns(); i > 0; i-- {
|
for i := p.minConns - p.Stat().TotalConns(); i > 0; i-- {
|
||||||
go p.p.CreateResource(context.Background())
|
go func() {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
p.p.CreateResource(ctx)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue