From 45793c9a1fbcc6fd055dd9f8131a634eaba6bc69 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Wed, 13 Jul 2022 11:09:06 -0400 Subject: [PATCH] tweak postgres connection --- internal/cmdutil/cmdutil.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cmdutil/cmdutil.go b/internal/cmdutil/cmdutil.go index 7aea93b..2905b3a 100644 --- a/internal/cmdutil/cmdutil.go +++ b/internal/cmdutil/cmdutil.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "time" "github.com/DataDog/datadog-go/statsd" "github.com/adjust/rmq/v4" @@ -68,7 +69,8 @@ func NewDatabasePool(ctx context.Context, maxConns int) (*pgxpool.Pool, error) { // Setting the build statement cache to nil helps this work with pgbouncer config.ConnConfig.BuildStatementCache = nil config.ConnConfig.PreferSimpleProtocol = true - + config.MaxConnLifetime = 1 * time.Hour + config.MaxConnIdleTime = 30 * time.Second return pgxpool.ConnectConfig(ctx, config) }