2
0

Add a timeout to pgxpool min connection creation

Ensure that CreateResource can't hang.
This commit is contained in:
Jack Christensen
2020-02-05 11:25:15 -06:00
parent cb1a1ebefa
commit 22ad987698
+5 -1
View File
@@ -323,7 +323,11 @@ func (p *Pool) checkIdleConnsHealth() {
func (p *Pool) checkMinConns() {
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)
}()
}
}