From 776f33bdbddcd47799f8b9b795a012ddf88b12d0 Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 26 Mar 2020 16:19:29 +0800 Subject: [PATCH] config, server: change the default value of max-server-connections --- config/config.go | 2 +- config/config.toml.example | 4 ++-- config/config_test.go | 1 + server/server.go | 5 +++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index cce5a209a1f6b..d029e3dd7323b 100644 --- a/config/config.go +++ b/config/config.go @@ -526,7 +526,7 @@ var defaultConf = Config{ SplitRegionMaxNum: 1000, RepairMode: false, RepairTableList: []string{}, - MaxServerConnections: 4096, + MaxServerConnections: 0, TxnLocalLatches: TxnLocalLatches{ Enabled: false, Capacity: 2048000, diff --git a/config/config.toml.example b/config/config.toml.example index 24a5c0aadc329..6f92821350c3e 100644 --- a/config/config.toml.example +++ b/config/config.toml.example @@ -99,8 +99,8 @@ repair-mode = false # In repair mode, repairing table which is not in repair list will get wrong database or wrong table error. repair-table-list = [] -# The maximum permitted number of simultaneous client connections. -max-server-connections = 4096 +# The maximum permitted number of simultaneous client connections. When the value is 0, the number of connections is unlimited. +max-server-connections = 0 # Whether new collations are enabled, as indicated by its name, this configuration entry take effect ONLY when a TiDB cluster bootstraps for the first time. new_collations_enabled_on_first_bootstrap = false diff --git a/config/config_test.go b/config/config_test.go index abdc65dec92b2..9376aed1a9cab 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -171,6 +171,7 @@ unrecognized-option-test = true c.Assert(f.Sync(), IsNil) c.Assert(conf.Load(configFile), ErrorMatches, "(?:.|\n)*unknown configuration option(?:.|\n)*") + c.Assert(conf.MaxServerConnections, Equals, uint32(0)) f.Truncate(0) f.Seek(0, 0) diff --git a/server/server.go b/server/server.go index f4685303864b4..934ed126a3c88 100644 --- a/server/server.go +++ b/server/server.go @@ -458,6 +458,11 @@ func (cc *clientConn) connectInfo() *variable.ConnectionInfo { } func (s *Server) checkConnectionCount() error { + // When the value of MaxServerConnections is 0, the number of connections is unlimited. + if int(s.cfg.MaxServerConnections) == 0 { + return nil + } + s.rwlock.RLock() conns := len(s.clients) s.rwlock.RUnlock()