From 9e2b65428434231584c4a51831bd0c9ac4fa0c4e Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Fri, 17 May 2024 12:49:08 -0700 Subject: [PATCH] Aggressively disallow further connections, fixes #476 --- Changes.md | 2 ++ server/config.go | 2 +- server/server.go | 2 ++ server/server_test.go | 1 + webui/web_test.go | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index a58ca1c..0771683 100644 --- a/Changes.md +++ b/Changes.md @@ -4,6 +4,8 @@ Changelog: Faktory || [Faktory Enterprise](https://github.com/contribsys/faktory ## 1.9.0 +- Faktory now refuses further connections on :7419 if the connection count is larger than + allowed, 2000 in Faktory or your licensed amount in Faktory Enterprise. [#476] - The `INFO` response has changed slightly, all elements now have well-defined types [#474] Deprecate `client.Info` Go API, add new `client.CurrentState` Go API which is almost identical to `client.Info` but has a strongly-typed response. diff --git a/server/config.go b/server/config.go index 165eaa0..e16dd2f 100644 --- a/server/config.go +++ b/server/config.go @@ -2,7 +2,7 @@ package server import "github.com/contribsys/faktory/util" -var DefaultMaxPoolSize = 1000 +var DefaultMaxPoolSize = 2000 type ServerOptions struct { Binding string diff --git a/server/server.go b/server/server.go index 6aefe58..e3d3cc8 100644 --- a/server/server.go +++ b/server/server.go @@ -364,6 +364,8 @@ func (s *Server) processLines(conn *Connection) { // This will trigger in Faktory Enterprise if over the licensed connection count. util.Warnf("%s has over %d active client connections and may exhibit poor performance. Ensure your worker processes are using no more than your licensed connection count.", client.Name, s.Options.PoolSize) } + _ = conn.Error("Overloaded", fmt.Errorf("too many connections: %d", s.Stats.Connections)) + return } for { diff --git a/server/server_test.go b/server/server_test.go index ee0c1aa..5207120 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -33,6 +33,7 @@ func runServer(binding string, runner func()) { StorageDirectory: dir, RedisSock: sock, ConfigDirectory: os.ExpandEnv("test/.faktory"), + PoolSize: DefaultMaxPoolSize, } s, err := NewServer(opts) if err != nil { diff --git a/webui/web_test.go b/webui/web_test.go index 7915a16..79765b5 100644 --- a/webui/web_test.go +++ b/webui/web_test.go @@ -100,6 +100,7 @@ func bootRuntime(t *testing.T, name string, fn func(*WebUI, *server.Server, *tes Binding: "localhost:7418", StorageDirectory: dir, RedisSock: sock, + PoolSize: server.DefaultMaxPoolSize, }) if err != nil {