diff --git a/internal/database/cockroach/crdb.go b/internal/database/cockroach/crdb.go index 2aeb295390..2f685f6d92 100644 --- a/internal/database/cockroach/crdb.go +++ b/internal/database/cockroach/crdb.go @@ -81,7 +81,11 @@ func (c *Config) Connect(useAdmin bool, pusherRatio, spoolerRatio float64, purpo if err != nil { return nil, err } - config.MaxConns = int32(connConfig.MaxOpenConns) + + if connConfig.MaxOpenConns != 0 { + config.MaxConns = int32(connConfig.MaxOpenConns) + } + config.MaxConnLifetime = c.MaxConnLifetime config.MaxConnIdleTime = c.MaxConnIdleTime diff --git a/internal/database/postgres/pg.go b/internal/database/postgres/pg.go index 0870d6243c..ecafbe877a 100644 --- a/internal/database/postgres/pg.go +++ b/internal/database/postgres/pg.go @@ -82,7 +82,11 @@ func (c *Config) Connect(useAdmin bool, pusherRatio, spoolerRatio float64, purpo if err != nil { return nil, err } - config.MaxConns = int32(connConfig.MaxOpenConns) + + if connConfig.MaxOpenConns != 0 { + config.MaxConns = int32(connConfig.MaxOpenConns) + } + config.MaxConnLifetime = c.MaxConnLifetime config.MaxConnIdleTime = c.MaxConnIdleTime