2
0

Fix: pgxpool: background health check cannot overflow pool

It was previously possible for a connection to be created while the
background health check was running. The health check could create
connection(s) in excess of the maximum pool size in this case.

https://github.com/jackc/pgx/issues/1660
This commit is contained in:
Jack Christensen
2023-07-15 10:07:26 -05:00
parent f47f0cf823
commit c513e2e435
3 changed files with 7 additions and 1 deletions
+4
View File
@@ -477,6 +477,10 @@ func (p *Pool) createIdleResources(parentCtx context.Context, targetResources in
go func() {
atomic.AddInt64(&p.newConnsCount, 1)
err := p.p.CreateResource(ctx)
// Ignore ErrNotAvailable since it means that the pool has become full since we started creating resource.
if err == puddle.ErrNotAvailable {
err = nil
}
errs <- err
}()
}