From 058f346079e1eb3a0d77bd7e409695c4a2c412e3 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 20 Nov 2021 11:19:10 -0600 Subject: [PATCH] Start pgxpool background health check after initial connections Otherwise the health check and the create initial connection(s) may both create connections. While this generally wouldn't be a real problem it did cause TestPoolBackgroundChecksMinConns to flicker on CI. --- pgxpool/pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgxpool/pool.go b/pgxpool/pool.go index 86ba40c9..f287ad88 100644 --- a/pgxpool/pool.go +++ b/pgxpool/pool.go @@ -222,8 +222,6 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) { config.MaxConns, ) - go p.backgroundHealthCheck() - if !config.LazyConnect { if err := p.createIdleResources(ctx, int(p.minConns)); err != nil { // Couldn't create resources for minpool size. Close unhealthy pool. @@ -240,6 +238,8 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) { res.Release() } + go p.backgroundHealthCheck() + return p, nil }