diff --git a/lib/gat/modes/zalando_operator_discovery/server.go b/lib/gat/modes/zalando_operator_discovery/server.go index 7153483a8482c3f6a0aa4acc151e12e28fd353e4..0d3e656a43b341c09e1cb1efe5a1a6537cfcb9b5 100644 --- a/lib/gat/modes/zalando_operator_discovery/server.go +++ b/lib/gat/modes/zalando_operator_discovery/server.go @@ -138,12 +138,22 @@ func (T *Server) addPool(name string, userCreds, serverCreds auth.Credentials, d } poolOptions := pool.Options{ - Credentials: userCreds, + Credentials: userCreds, + ServerReconnectInitialTime: 5 * time.Second, + ServerReconnectMaxTime: 5 * time.Second, + TrackedParameters: []strutil.CIString{ + strutil.MakeCIString("client_encoding"), + strutil.MakeCIString("datestyle"), + strutil.MakeCIString("timezone"), + strutil.MakeCIString("standard_conforming_strings"), + strutil.MakeCIString("application_name"), + }, } switch T.opConfig.Mode { case "transaction": poolOptions = transaction.Apply(poolOptions) case "session": + poolOptions.ServerResetQuery = "discard all" poolOptions = session.Apply(poolOptions) default: log.Printf(`unknown pool mode "%s"`, T.opConfig.Mode) @@ -151,8 +161,14 @@ func (T *Server) addPool(name string, userCreds, serverCreds auth.Credentials, d } p := pool.NewPool(poolOptions) + var maxConnections int + if T.opConfig.MaxDBConnections != nil { + maxConnections = int(*T.opConfig.MaxDBConnections) + } + recipeOptions := recipe.Options{ - Dialer: d, + Dialer: d, + MaxConnections: maxConnections, } r := recipe.NewRecipe(recipeOptions) diff --git a/lib/gat/pool/pool.go b/lib/gat/pool/pool.go index 77bcb2e085522b32104247e2f39ce6fcfce3c3b9..847567c01a889173fe9e094537f5f09213bdd1f0 100644 --- a/lib/gat/pool/pool.go +++ b/lib/gat/pool/pool.go @@ -280,9 +280,9 @@ func (T *Pool) acquireServer(client *Client) *Server { } func (T *Pool) releaseServer(server *Server) { - server.SetState(metrics.ConnStateRunningResetQuery, uuid.Nil) - if T.options.ServerResetQuery != "" { + server.SetState(metrics.ConnStateRunningResetQuery, uuid.Nil) + err := backends.QueryString(new(backends.Context), server.GetReadWriter(), T.options.ServerResetQuery) if err != nil { T.removeServer(server)