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:
@@ -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
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user