Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
39 changes: 39 additions & 0 deletions go/cmd/dolt/commands/sqlserver/command_line_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"

"github.com/dolthub/dolt/go/libraries/doltcore/servercfg"
"github.com/dolthub/dolt/go/libraries/utils/filesys"
Expand All @@ -42,6 +43,8 @@ type commandLineServerConfig struct {
autoCommit bool
doltTransactionCommit bool
maxConnections uint64
maxWaitConnections uint32
maxWaitConnsTimeout time.Duration
tlsKey string
tlsCert string
requireSecureTransport bool
Expand Down Expand Up @@ -72,6 +75,8 @@ func DefaultCommandLineServerConfig() *commandLineServerConfig {
logFormat: servercfg.DefaultLogFormat,
autoCommit: servercfg.DefaultAutoCommit,
maxConnections: servercfg.DefaultMaxConnections,
maxWaitConnections: servercfg.DefaultMaxWaitConnections,
maxWaitConnsTimeout: servercfg.DefaultMaxWaitConnectionsTimeout,
dataDir: servercfg.DefaultDataDir,
cfgDir: filepath.Join(servercfg.DefaultDataDir, servercfg.DefaultCfgDir),
privilegeFilePath: filepath.Join(servercfg.DefaultDataDir, servercfg.DefaultCfgDir, servercfg.DefaultPrivilegeFilePath),
Expand Down Expand Up @@ -169,6 +174,18 @@ func NewCommandLineConfig(creds *cli.UserPassword, apr *argparser.ArgParseResult
config.withMaxConnections(uint64(maxConnections))
}

if maxWaitConnections, ok := apr.GetInt(maxWaitConnectionsFlag); ok {
config.withMaxWaitConnections(uint32(maxWaitConnections))
}

if maxWaitConnsTimeoutStr, ok := apr.GetValue(maxWaitConsTimeoutFlag); ok {
maxWaitConnsTimeout, err := time.ParseDuration(maxWaitConnsTimeoutStr)
if err != nil {
return nil, fmt.Errorf("invalid duration value for --max-wait-connections-timeout '%s'", maxWaitConnsTimeoutStr)
}
config.withMaxWaitConnectionsTimeout(maxWaitConnsTimeout)
}

config.autoCommit = !apr.Contains(noAutoCommitFlag)
if apr.Contains(noAutoCommitFlag) {
config.valuesSet[servercfg.AutoCommitKey] = struct{}{}
Expand Down Expand Up @@ -258,6 +275,16 @@ func (cfg *commandLineServerConfig) MaxConnections() uint64 {
return cfg.maxConnections
}

// MaxWaitConnections returns the maximum number of simultaneous connections that the server will allow to block waiting
// for a connection before new connections result in immediate rejection.
func (cfg *commandLineServerConfig) MaxWaitConnections() uint32 {
return cfg.maxWaitConnections
}

func (cfg *commandLineServerConfig) MaxWaitConnectionsTimeout() time.Duration {
return cfg.maxWaitConnsTimeout
}

// TLSKey returns a path to the servers PEM-encoded private TLS key. "" if there is none.
func (cfg *commandLineServerConfig) TLSKey() string {
return cfg.tlsKey
Expand Down Expand Up @@ -425,6 +452,18 @@ func (cfg *commandLineServerConfig) withMaxConnections(maxConnections uint64) *c
return cfg
}

func (cfg *commandLineServerConfig) withMaxWaitConnections(maxWaitConnections uint32) *commandLineServerConfig {
cfg.maxWaitConnections = maxWaitConnections
cfg.valuesSet[servercfg.MaxWaitConnectionsKey] = struct{}{}
return cfg
}

func (cfg *commandLineServerConfig) withMaxWaitConnectionsTimeout(maxWaitConnsTimeout time.Duration) *commandLineServerConfig {
cfg.maxWaitConnsTimeout = maxWaitConnsTimeout
cfg.valuesSet[servercfg.MaxWaitConnectionsTimeoutKey] = struct{}{}
return cfg
}

// withDataDir updates the path to a directory to use as the data dir.
func (cfg *commandLineServerConfig) withDataDir(dataDir string) *commandLineServerConfig {
cfg.dataDir = dataDir
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/dolt/commands/sqlserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,8 @@ func getConfigFromServerConfig(serverConfig servercfg.ServerConfig, plf server.P
serverConf.ConnReadTimeout = readTimeout
serverConf.ConnWriteTimeout = writeTimeout
serverConf.MaxConnections = serverConfig.MaxConnections()
serverConf.MaxWaitConnections = serverConfig.MaxWaitConnections()
serverConf.MaxWaitConnectionsTimeout = serverConfig.MaxWaitConnectionsTimeout()
serverConf.TLSConfig = tlsConfig
serverConf.RequireSecureTransport = serverConfig.RequireSecureTransport()
serverConf.MaxLoggedQueryLen = serverConfig.MaxLoggedQueryLen()
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/dolt/commands/sqlserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ listener:
# host: localhost
# port: 3306
# max_connections: 1000
# back_log: 50
# max_connections_timeout_millis: 60000
read_timeout_millis: 11000
write_timeout_millis: 11000
# tls_key: key.pem
Expand Down
8 changes: 8 additions & 0 deletions go/cmd/dolt/commands/sqlserver/sqlserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const (
configFileFlag = "config"
queryParallelismFlag = "query-parallelism"
maxConnectionsFlag = "max-connections"
maxWaitConnectionsFlag = "back-log"
maxWaitConsTimeoutFlag = "max-connections-timeout"
allowCleartextPasswordsFlag = "allow-cleartext-passwords"
socketFlag = "socket"
remotesapiPortFlag = "remotesapi-port"
Expand Down Expand Up @@ -107,6 +109,10 @@ SUPPORTED CONFIG FILE FIELDS:

{{.EmphasisLeft}}listener.max_connections{{.EmphasisRight}}: The number of simultaneous connections that the server will accept

{{.EmphasisLeft}}listener.back_log{{.EmphasisRight}}: The number of simultaneous connections that the server will allow to block waiting for a connection before new connections result in immediate rejection. Default 50.

{{.EmphasisLeft}}listener.max_wait_connections_timeout{{.EmphasisRight}}: The maximum amount of time that a connection will block waiting for a connection before being rejected.

{{.EmphasisLeft}}listener.read_timeout_millis{{.EmphasisRight}}: The number of milliseconds that the server will wait for a read operation

{{.EmphasisLeft}}listener.write_timeout_millis{{.EmphasisRight}}: The number of milliseconds that the server will wait for a write operation
Expand Down Expand Up @@ -179,6 +185,8 @@ func (cmd SqlServerCmd) ArgParserWithName(name string) *argparser.ArgParser {
ap.SupportsFlag(noAutoCommitFlag, "", "Set @@autocommit = off for the server.")
ap.SupportsInt(queryParallelismFlag, "", "num-go-routines", "Deprecated, no effect in current versions of Dolt")
ap.SupportsInt(maxConnectionsFlag, "", "max-connections", fmt.Sprintf("Set the number of connections handled by the server. Defaults to `%d`.", serverConfig.MaxConnections()))
ap.SupportsInt(maxWaitConnectionsFlag, "", "back-log", fmt.Sprintf("Set the number of connections that can block waiting for a connection before new connections are rejected. Defaults to `%d`.", serverConfig.MaxWaitConnections()))
ap.SupportsString(maxWaitConsTimeoutFlag, "", "max-connections-timeout", fmt.Sprintf("Set the maximum duration that a connection will block waiting for a connection before being rejected. Defaults to `%v`.", serverConfig.MaxWaitConnectionsTimeout()))
ap.SupportsString(commands.PrivsFilePathFlag, "", "privilege file", "Path to a file to load and store users and grants. Defaults to `$doltcfg-dir/privileges.db`. Will be created as needed.")
ap.SupportsString(commands.BranchCtrlPathFlag, "", "branch control file", "Path to a file to load and store branch control permissions. Defaults to `$doltcfg-dir/branch_control.db`. Will be created as needed.")
ap.SupportsString(allowCleartextPasswordsFlag, "", "allow-cleartext-passwords", "Allows use of cleartext passwords. Defaults to false.")
Expand Down
4 changes: 2 additions & 2 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/dolthub/fslock v0.0.3
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
github.com/dolthub/vitess v0.0.0-20250320231804-0e77d549294c
github.com/dolthub/vitess v0.0.0-20250325024605-8131be3ca6d3
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.13.0
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568
Expand Down Expand Up @@ -60,7 +60,7 @@ require (
github.com/creasty/defaults v1.6.0
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.19.1-0.20250321183729-47285a54773c
github.com/dolthub/go-mysql-server v0.19.1-0.20250325031739-45c4c4ce0449
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/esote/minmaxheap v1.0.0
github.com/goccy/go-json v0.10.2
Expand Down
8 changes: 4 additions & 4 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20250319212010-451ea8d003fa h1:NFbzJ4wjWRz32nz2EimbrHpRx1Xt6k+IaR8N+j4x62k=
github.com/dolthub/go-icu-regex v0.0.0-20250319212010-451ea8d003fa/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.19.1-0.20250321183729-47285a54773c h1:bCPelFSgt6aOPUqvrKV3OY8S9tjcBxQTgFNGARsrcSU=
github.com/dolthub/go-mysql-server v0.19.1-0.20250321183729-47285a54773c/go.mod h1:WyimbJzsrNiYsQ7nfnXYLIoFAfNX0I7rHH1WaDt7faM=
github.com/dolthub/go-mysql-server v0.19.1-0.20250325031739-45c4c4ce0449 h1:pW0XNR2cdUTGmLXyvFux5hZQRFJlHK12fWeC5vdmWNo=
github.com/dolthub/go-mysql-server v0.19.1-0.20250325031739-45c4c4ce0449/go.mod h1:vKBT9NZQDwG0Db6CT4D92Mw6kaJpWbIDy1hBX7XWUCA=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand All @@ -231,8 +231,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/vitess v0.0.0-20250320231804-0e77d549294c h1:Dv2DfEGb8WRBi8I5KF5Sy39TuZi/FI692mpobKWcv4g=
github.com/dolthub/vitess v0.0.0-20250320231804-0e77d549294c/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dolthub/vitess v0.0.0-20250325024605-8131be3ca6d3 h1:euU+adNAYw46Zcp1HnoaSDWhqjfaL8s/1SPU+i16gYM=
github.com/dolthub/vitess v0.0.0-20250325024605-8131be3ca6d3/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
Expand Down
56 changes: 34 additions & 22 deletions go/libraries/doltcore/servercfg/serverconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
)

var DefaultUnixSocketFilePath = DefaultMySQLUnixSocketFilePath
Expand All @@ -47,28 +48,30 @@ const (
)

const (
DefaultHost = "localhost"
DefaultPort = 3306
DefaultUser = "root"
DefaultPass = ""
DefaultTimeout = 8 * 60 * 60 * 1000 // 8 hours, same as MySQL
DefaultReadOnly = false
DefaultLogLevel = LogLevel_Info
DefaultLogFormat = LogFormat_Text
DefaultAutoCommit = true
DefaultAutoGCBehaviorEnable = false
DefaultDoltTransactionCommit = false
DefaultMaxConnections = 1000
DefaultDataDir = "."
DefaultCfgDir = ".doltcfg"
DefaultPrivilegeFilePath = "privileges.db"
DefaultBranchControlFilePath = "branch_control.db"
DefaultMetricsHost = ""
DefaultMetricsPort = -1
DefaultAllowCleartextPasswords = false
DefaultMySQLUnixSocketFilePath = "/tmp/mysql.sock"
DefaultMaxLoggedQueryLen = 0
DefaultEncodeLoggedQuery = false
DefaultHost = "localhost"
DefaultPort = 3306
DefaultUser = "root"
DefaultPass = ""
DefaultTimeout = 8 * 60 * 60 * 1000 // 8 hours, same as MySQL
DefaultReadOnly = false
DefaultLogLevel = LogLevel_Info
DefaultLogFormat = LogFormat_Text
DefaultAutoCommit = true
DefaultAutoGCBehaviorEnable = false
DefaultDoltTransactionCommit = false
DefaultMaxConnections = 1000
DefaultMaxWaitConnections = 50
DefaultMaxWaitConnectionsTimeout = 60 * time.Second
DefaultDataDir = "."
DefaultCfgDir = ".doltcfg"
DefaultPrivilegeFilePath = "privileges.db"
DefaultBranchControlFilePath = "branch_control.db"
DefaultMetricsHost = ""
DefaultMetricsPort = -1
DefaultAllowCleartextPasswords = false
DefaultMySQLUnixSocketFilePath = "/tmp/mysql.sock"
DefaultMaxLoggedQueryLen = 0
DefaultEncodeLoggedQuery = false
)

func ptr[T any](t T) *T {
Expand Down Expand Up @@ -159,6 +162,11 @@ type ServerConfig interface {
CfgDir() string
// MaxConnections returns the maximum number of simultaneous connections the server will allow. The default is 1
MaxConnections() uint64
// MaxWaitConnections returns the maximum number of simultaneous connections that the server will allow to block waiting
// for a connection before new connections result in immediate rejection
MaxWaitConnections() uint32
// MaxWaitConnectionsTimeout returns the maximum amount of time that a connection will block waiting for a connection
MaxWaitConnectionsTimeout() time.Duration
// TLSKey returns a path to the servers PEM-encoded private TLS key. "" if there is none.
TLSKey() string
// TLSCert returns a path to the servers PEM-encoded TLS certificate chain. "" if there is none.
Expand Down Expand Up @@ -240,6 +248,8 @@ func defaultServerConfigYAML() *YAMLConfig {
HostStr: ptr(DefaultHost),
PortNumber: ptr(DefaultPort),
MaxConnections: ptr(uint64(DefaultMaxConnections)),
BackLog: ptr(uint32(DefaultMaxWaitConnections)),
MaxConnectionsTimeoutMs: ptr(uint64(DefaultMaxWaitConnectionsTimeout.Milliseconds())),
ReadTimeoutMillis: ptr(uint64(DefaultTimeout)),
WriteTimeoutMillis: ptr(uint64(DefaultTimeout)),
AllowCleartextPasswords: ptr(DefaultAllowCleartextPasswords),
Expand Down Expand Up @@ -306,6 +316,8 @@ const (
DataDirKey = "data_dir"
CfgDirKey = "cfg_dir"
MaxConnectionsKey = "max_connections"
MaxWaitConnectionsKey = "back_log"
MaxWaitConnectionsTimeoutKey = "max_connections_timeout"
TLSKeyKey = "tls_key"
TLSCertKey = "tls_cert"
RequireSecureTransportKey = "require_secure_transport"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ListenerConfig servercfg.ListenerYAMLConfig 0.0.0 listener,omitempty
-HostStr *string 0.0.0 host,omitempty
-PortNumber *int 0.0.0 port,omitempty
-MaxConnections *uint64 0.0.0 max_connections,omitempty
-BackLog *uint32 0.0.0 back_log,omitempty
-MaxConnectionsTimeoutMs *uint64 0.0.0 max_connections_timeout_millis,omitempty
-ReadTimeoutMillis *uint64 0.0.0 read_timeout_millis,omitempty
-WriteTimeoutMillis *uint64 0.0.0 write_timeout_millis,omitempty
-TLSKey *string 0.0.0 tls_key,omitempty
Expand Down Expand Up @@ -64,4 +66,4 @@ ClusterCfg *servercfg.ClusterYAMLConfig 0.0.0 cluster,omitempty
--TLSCert_ string 0.0.0 tls_cert
--TLSCA_ string 0.0.0 tls_ca
--URLMatches []string 0.0.0 server_name_urls
--DNSMatches []string 0.0.0 server_name_dns
--DNSMatches []string 0.0.0 server_name_dns
43 changes: 38 additions & 5 deletions go/libraries/doltcore/servercfg/yaml_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"path/filepath"
"strings"
"time"
"unicode"
"unicode/utf8"

Expand Down Expand Up @@ -77,11 +78,13 @@ type UserYAMLConfig struct {

// ListenerYAMLConfig contains information on the network connection that the server will open
type ListenerYAMLConfig struct {
HostStr *string `yaml:"host,omitempty"`
PortNumber *int `yaml:"port,omitempty"`
MaxConnections *uint64 `yaml:"max_connections,omitempty"`
ReadTimeoutMillis *uint64 `yaml:"read_timeout_millis,omitempty"`
WriteTimeoutMillis *uint64 `yaml:"write_timeout_millis,omitempty"`
HostStr *string `yaml:"host,omitempty"`
PortNumber *int `yaml:"port,omitempty"`
MaxConnections *uint64 `yaml:"max_connections,omitempty"`
BackLog *uint32 `yaml:"back_log,omitempty"`
MaxConnectionsTimeoutMs *uint64 `yaml:"max_connections_timeout_millis,omitempty"`
Comment thread
macneale4 marked this conversation as resolved.
Outdated
ReadTimeoutMillis *uint64 `yaml:"read_timeout_millis,omitempty"`
WriteTimeoutMillis *uint64 `yaml:"write_timeout_millis,omitempty"`
// TLSKey is a file system path to an unencrypted private TLS key in PEM format.
TLSKey *string `yaml:"tls_key,omitempty"`
// TLSCert is a file system path to a TLS certificate chain in PEM format.
Expand Down Expand Up @@ -197,6 +200,8 @@ func ServerConfigAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
HostStr: ptr(cfg.Host()),
PortNumber: ptr(cfg.Port()),
MaxConnections: ptr(cfg.MaxConnections()),
BackLog: ptr(cfg.MaxWaitConnections()),
MaxConnectionsTimeoutMs: ptr(uint64(cfg.MaxWaitConnectionsTimeout().Milliseconds())),
ReadTimeoutMillis: ptr(cfg.ReadTimeout()),
WriteTimeoutMillis: ptr(cfg.WriteTimeout()),
TLSKey: nillableStrPtr(cfg.TLSKey()),
Expand Down Expand Up @@ -267,6 +272,8 @@ func ServerConfigSetValuesAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
HostStr: zeroIf(ptr(cfg.Host()), !cfg.ValueSet(HostKey)),
PortNumber: zeroIf(ptr(cfg.Port()), !cfg.ValueSet(PortKey)),
MaxConnections: zeroIf(ptr(cfg.MaxConnections()), !cfg.ValueSet(MaxConnectionsKey)),
BackLog: zeroIf(ptr(cfg.MaxWaitConnections()), !cfg.ValueSet(MaxWaitConnectionsKey)),
MaxConnectionsTimeoutMs: zeroIf(ptr(uint64(cfg.MaxWaitConnectionsTimeout().Milliseconds())), !cfg.ValueSet(MaxWaitConnectionsTimeoutKey)),
ReadTimeoutMillis: zeroIf(ptr(cfg.ReadTimeout()), !cfg.ValueSet(ReadTimeoutKey)),
WriteTimeoutMillis: zeroIf(ptr(cfg.WriteTimeout()), !cfg.ValueSet(WriteTimeoutKey)),
TLSKey: zeroIf(ptr(cfg.TLSKey()), !cfg.ValueSet(TLSKeyKey)),
Expand Down Expand Up @@ -487,6 +494,12 @@ func (cfg YAMLConfig) withDefaultsFilledIn() YAMLConfig {
if withDefaults.ListenerConfig.MaxConnections == nil {
withDefaults.ListenerConfig.MaxConnections = defaults.ListenerConfig.MaxConnections
}
if withDefaults.ListenerConfig.BackLog == nil {
withDefaults.ListenerConfig.BackLog = defaults.ListenerConfig.BackLog
}
if withDefaults.ListenerConfig.MaxConnectionsTimeoutMs == nil {
withDefaults.ListenerConfig.MaxConnectionsTimeoutMs = defaults.ListenerConfig.MaxConnectionsTimeoutMs
}
if withDefaults.ListenerConfig.ReadTimeoutMillis == nil {
withDefaults.ListenerConfig.ReadTimeoutMillis = defaults.ListenerConfig.ReadTimeoutMillis
}
Expand Down Expand Up @@ -659,6 +672,22 @@ func (cfg YAMLConfig) MaxConnections() uint64 {
return *cfg.ListenerConfig.MaxConnections
}

func (cfg YAMLConfig) MaxWaitConnections() uint32 {
if cfg.ListenerConfig.BackLog == nil {
return DefaultMaxWaitConnections
}

return *cfg.ListenerConfig.BackLog
}

func (cfg YAMLConfig) MaxWaitConnectionsTimeout() time.Duration {
if cfg.ListenerConfig.MaxConnectionsTimeoutMs == nil {
return DefaultMaxWaitConnectionsTimeout
}

return time.Duration(*cfg.ListenerConfig.MaxConnectionsTimeoutMs) * time.Millisecond
}

// DisableClientMultiStatements returns true if the server should run in a mode
// where the CLIENT_MULTI_STATEMENTS option are ignored and every incoming
// ComQuery packet is assumed to be a standalone query.
Expand Down Expand Up @@ -946,6 +975,10 @@ func (cfg YAMLConfig) ValueSet(value string) bool {
return cfg.ListenerConfig.WriteTimeoutMillis != nil
case MaxConnectionsKey:
return cfg.ListenerConfig.MaxConnections != nil
case MaxWaitConnectionsKey:
return cfg.ListenerConfig.BackLog != nil
case MaxWaitConnectionsTimeoutKey:
return cfg.ListenerConfig.MaxConnectionsTimeoutMs != nil
case EventSchedulerKey:
return cfg.BehaviorConfig.EventSchedulerStatus != nil
}
Expand Down
2 changes: 2 additions & 0 deletions go/libraries/doltcore/servercfg/yaml_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ listener:
host: localhost
port: 3306
max_connections: 1000
back_log: 50
max_connections_timeout_millis: 60000
read_timeout_millis: 28800000
write_timeout_millis: 28800000

Expand Down
Loading