From 552c00fe2c56f945766c81aeb6f496cc5f01fcb0 Mon Sep 17 00:00:00 2001 From: Garet Halliday <me@garet.holiday> Date: Thu, 25 Apr 2024 15:51:37 -0500 Subject: [PATCH] dadsad --- lib/gat/handlers/pool/spool/kitchen/chef.go | 4 ++++ lib/gat/handlers/pool/spool/pool.go | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/gat/handlers/pool/spool/kitchen/chef.go b/lib/gat/handlers/pool/spool/kitchen/chef.go index 60c70aca..c2b7b0cb 100644 --- a/lib/gat/handlers/pool/spool/kitchen/chef.go +++ b/lib/gat/handlers/pool/spool/kitchen/chef.go @@ -88,7 +88,10 @@ func (T *Chef) forget(name string) []*fed.Conn { for conn := range r.conns { conns = append(conns, conn) _ = conn.Close() + r.recipe.Free() + delete(T.byConn, conn) + delete(r.conns, conn) } T.order = slices.Remove(T.order, r) @@ -263,6 +266,7 @@ func (T *Chef) Cook() (*fed.Conn, error) { } } + T.config.Logger.Warn("no available recipes to scale up pool") return nil, ErrNoRecipes } diff --git a/lib/gat/handlers/pool/spool/pool.go b/lib/gat/handlers/pool/spool/pool.go index 3c6569c4..fe210a68 100644 --- a/lib/gat/handlers/pool/spool/pool.go +++ b/lib/gat/handlers/pool/spool/pool.go @@ -161,12 +161,15 @@ func (T *Pool) ScaleDown(now time.Time) time.Duration { delete(T.serversByID, s.ID) delete(T.serversByConn, s.Conn) } - } else if idle > m { - m = idle + } else { + util := T.config.IdleTimeout - idle + if idle < m { + m = util + } } } - return T.config.IdleTimeout - m + return m } func (T *Pool) ScaleLoop() { -- GitLab