From 69fdc51d1804dc607bb3f9aeb7080a7e149953dc Mon Sep 17 00:00:00 2001 From: Esme Lamb Date: Thu, 9 Jan 2025 14:33:55 +1100 Subject: [PATCH] sort of builds? --- go/vt/vtgateproxy/mysql_server.go | 10 +++++----- go/vt/vtgateproxy/vtgateproxy.go | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/go/vt/vtgateproxy/mysql_server.go b/go/vt/vtgateproxy/mysql_server.go index 7d0208ceaa6..ea0105fe9fe 100644 --- a/go/vt/vtgateproxy/mysql_server.go +++ b/go/vt/vtgateproxy/mysql_server.go @@ -73,7 +73,7 @@ var ( mysqlSslServerCA = flag.String("mysql_server_ssl_server_ca", "", "path to server CA in PEM format, which will be combine with server cert, return full certificate chain to clients") - mysqlSlowConnectWarnThreshold = flag.Duration("mysql_slow_connect_warn_threshold", 0, "Warn if it takes more than the given threshold for a mysql connection to establish") + mysqlSlowConnectWarnThreshold = flag.Int64("mysql_slow_connect_warn_threshold", 0, "Warn if it takes more than the given threshold for a mysql connection to establish") mysqlConnReadTimeout = flag.Duration("mysql_server_read_timeout", 0, "connection read timeout") mysqlConnWriteTimeout = flag.Duration("mysql_server_write_timeout", 0, "connection write timeout") @@ -508,11 +508,11 @@ func initMySQLProtocol() { _ = initTLSConfig(mysqlListener, *mysqlSslCert, *mysqlSslKey, *mysqlSslCa, *mysqlSslCrl, *mysqlSslServerCA, *mysqlServerRequireSecureTransport, tlsVersion) } - mysqlListener.AllowClearTextWithoutTLS.Set(*mysqlAllowClearTextWithoutTLS) + mysqlListener.AllowClearTextWithoutTLS.Store(*mysqlAllowClearTextWithoutTLS) // Check for the connection threshold if *mysqlSlowConnectWarnThreshold != 0 { log.Infof("setting mysql slow connection threshold to %v", mysqlSlowConnectWarnThreshold) - mysqlListener.SlowConnectWarnThreshold.Set(*mysqlSlowConnectWarnThreshold) + mysqlListener.SlowConnectWarnThreshold.Store(*mysqlSlowConnectWarnThreshold) } // Start listening for tcp go mysqlListener.Accept() @@ -536,7 +536,7 @@ func initMySQLProtocol() { // newMysqlUnixSocket creates a new unix socket mysql listener. If a socket file already exists, attempts // to clean it up. func newMysqlUnixSocket(address string, authServer mysql.AuthServer, handler mysql.Handler) (*mysql.Listener, error) { - listener, err := mysql.NewListener("unix", address, authServer, handler, *mysqlConnReadTimeout, *mysqlConnWriteTimeout, false, false) + listener, err := mysql.NewListener("unix", address, authServer, handler, *mysqlConnReadTimeout, *mysqlConnWriteTimeout, false, false, *mysqlKeepAlivePeriod, *mysqlServerFlushDelay) switch err := err.(type) { case nil: return listener, nil @@ -557,7 +557,7 @@ func newMysqlUnixSocket(address string, authServer mysql.AuthServer, handler mys log.Errorf("Couldn't remove existent socket file: %s", address) return nil, err } - listener, listenerErr := mysql.NewListener("unix", address, authServer, handler, *mysqlConnReadTimeout, *mysqlConnWriteTimeout, false, false) + listener, listenerErr := mysql.NewListener("unix", address, authServer, handler, *mysqlConnReadTimeout, *mysqlConnWriteTimeout, false, false, *mysqlKeepAlivePeriod, *mysqlServerFlushDelay) return listener, listenerErr default: return nil, err diff --git a/go/vt/vtgateproxy/vtgateproxy.go b/go/vt/vtgateproxy/vtgateproxy.go index 8de456781f3..c0afdf422a7 100644 --- a/go/vt/vtgateproxy/vtgateproxy.go +++ b/go/vt/vtgateproxy/vtgateproxy.go @@ -170,7 +170,10 @@ func (proxy *VTGateProxy) Execute(ctx context.Context, session *vtgateconn.VTGat // Intercept "use" statements since they just have to update the local session if strings.HasPrefix(sql, "use ") { - targetString := sqlescape.UnescapeID(sql[4:]) + targetString, err := sqlescape.UnescapeID(sql[4:]) + if err != nil { + return &sqltypes.Result{}, fmt.Errorf("failed to unescape use statement target string: %w", err) + } session.SessionPb().TargetString = targetString return &sqltypes.Result{}, nil }