From 8c138391723f1b434f6fc33ccdac81880a793bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rold=C3=A1n=20Betancort?= Date: Mon, 19 Feb 2024 10:29:17 +0000 Subject: [PATCH] fixes pgx min connection count always being set to max count the logic ignored teh provided `opts.MinOpenConns` and always defaulted to the max value provided. It affects both Postgres and CockroachDB datastores. --- internal/datastore/postgres/common/pgx.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/datastore/postgres/common/pgx.go b/internal/datastore/postgres/common/pgx.go index f254f11e2a..1e9f1db85e 100644 --- a/internal/datastore/postgres/common/pgx.go +++ b/internal/datastore/postgres/common/pgx.go @@ -249,9 +249,10 @@ func (opts PoolOptions) ConfigurePgx(pgxConfig *pgxpool.Config) { pgxConfig.MaxConns = int32(*opts.MaxOpenConns) } + // Default to keeping the pool maxed out at all times. + pgxConfig.MinConns = pgxConfig.MaxConns if opts.MinOpenConns != nil { - // Default to keeping the pool maxed out at all times. - pgxConfig.MinConns = pgxConfig.MaxConns + pgxConfig.MinConns = int32(*opts.MinOpenConns) } if pgxConfig.MaxConns > 0 && pgxConfig.MinConns > 0 && pgxConfig.MaxConns < pgxConfig.MinConns {