Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config, server: change the default value of max-server-connections #15726

Merged
merged 2 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ var defaultConf = Config{
SplitRegionMaxNum: 1000,
RepairMode: false,
RepairTableList: []string{},
MaxServerConnections: 4096,
MaxServerConnections: 0,
TxnLocalLatches: TxnLocalLatches{
Enabled: false,
Capacity: 2048000,
Expand Down
4 changes: 2 additions & 2 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down