Skip to content

Commit 8d9b0e5

Browse files
author
Yves Trudeau
committed
Added Config variables for max_allowed_packet, by default the current behavior is used
1 parent bf00608 commit 8d9b0e5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docker/Dockerfile.system

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN echo "ci_env_repo: $ci_env_repo"
88
RUN echo "ci_env_branch: $ci_env_branch"
99

1010
RUN apt-get update -q -y
11-
RUN apt-get install -y sudo haproxy python git jq rsync libaio1 libnuma1 default-mysql-client bsdmainutils less vim
11+
RUN apt-get install -y sudo haproxy python git jq rsync libaio1 libnuma1 default-mysql-client bsdmainutils less vim libncurses5
1212

1313
RUN mkdir /orchestrator
1414
WORKDIR /orchestrator

go/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type Configuration struct {
103103
MySQLTopologySSLSkipVerify bool // If true, do not strictly validate mutual TLS certs for Topology mysql instances
104104
MySQLTopologyUseMutualTLS bool // Turn on TLS authentication with the Topology MySQL instances
105105
MySQLTopologyUseMixedTLS bool // Mixed TLS and non-TLS authentication with the Topology MySQL instances
106+
MySQLTopologyMaxAllowedPacket int32 // max_allowed_packet value to use when connecting to the Topology mysql instance
106107
TLSCacheTTLFactor uint // Factor of InstancePollSeconds that we set as TLS info cache expiry
107108
BackendDB string // EXPERIMENTAL: type of backend db; either "mysql" or "sqlite3"
108109
SQLite3DataFile string // when BackendDB == "sqlite3", full path to sqlite3 datafile
@@ -129,6 +130,7 @@ type Configuration struct {
129130
MySQLOrchestratorUseMutualTLS bool // Turn on TLS authentication with the Orchestrator MySQL instance
130131
MySQLOrchestratorReadTimeoutSeconds int // Number of seconds before backend mysql read operation is aborted (driver-side)
131132
MySQLOrchestratorRejectReadOnly bool // Reject read only connections https://github.com/go-sql-driver/mysql#rejectreadonly
133+
MySQLOrchestratorMaxAllowedPacket int32 // max_allowed_packet to use when connecting to the Orchestrator mysql instance
132134
MySQLConnectTimeoutSeconds int // Number of seconds before connection is aborted (driver-side)
133135
MySQLDiscoveryReadTimeoutSeconds int // Number of seconds before topology mysql read operation is aborted (driver-side). Used for discovery queries.
134136
MySQLTopologyReadTimeoutSeconds int // Number of seconds before topology mysql read operation is aborted (driver-side). Used for all but discovery queries.
@@ -316,10 +318,12 @@ func newConfiguration() *Configuration {
316318
MySQLOrchestratorPort: 3306,
317319
MySQLTopologyUseMutualTLS: false,
318320
MySQLTopologyUseMixedTLS: true,
321+
MySQLTopologyMaxAllowedPacket: -1,
319322
MySQLOrchestratorUseMutualTLS: false,
320323
MySQLConnectTimeoutSeconds: 2,
321324
MySQLOrchestratorReadTimeoutSeconds: 30,
322325
MySQLOrchestratorRejectReadOnly: false,
326+
MySQLOrchestratorMaxAllowedPacket: -1,
323327
MySQLDiscoveryReadTimeoutSeconds: 10,
324328
MySQLTopologyReadTimeoutSeconds: 600,
325329
MySQLConnectionLifetimeSeconds: 0,

go/db/db.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func getMySQLURI() string {
5858
if mysqlURI != "" {
5959
return mysqlURI
6060
}
61-
mysqlURI := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?maxAllowedPacket=0&timeout=%ds&readTimeout=%ds&rejectReadOnly=%t&interpolateParams=true",
61+
mysqlURI := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?timeout=%ds&readTimeout=%ds&rejectReadOnly=%t&interpolateParams=true",
6262
config.Config.MySQLOrchestratorUser,
6363
config.Config.MySQLOrchestratorPassword,
6464
config.Config.MySQLOrchestratorHost,
@@ -71,6 +71,9 @@ func getMySQLURI() string {
7171
if config.Config.MySQLOrchestratorUseMutualTLS {
7272
mysqlURI, _ = SetupMySQLOrchestratorTLS(mysqlURI)
7373
}
74+
if config.Config.MySQLOrchestratorMaxAllowedPacket >= 0 {
75+
mysqlURI = fmt.Sprintf("%s&maxAllowedPacket=%d",mysqlURI,config.Config.MySQLOrchestratorMaxAllowedPacket)
76+
}
7477
return mysqlURI
7578
}
7679

@@ -95,6 +98,9 @@ func openTopology(host string, port int, readTimeout int) (db *sql.DB, err error
9598
readTimeout,
9699
)
97100

101+
if config.Config.MySQLTopologyMaxAllowedPacket >= 0 {
102+
mysqlURI = fmt.Sprintf("%s&maxAllowedPacket=%d",mysqlURI,config.Config.MySQLTopologyMaxAllowedPacket)
103+
}
98104
if config.Config.MySQLTopologyUseMutualTLS ||
99105
(config.Config.MySQLTopologyUseMixedTLS && requiresTLS(host, port, mysql_uri)) {
100106
if mysql_uri, err = SetupMySQLTopologyTLS(mysql_uri); err != nil {

0 commit comments

Comments
 (0)