diff --git a/examples/compose/docker-compose.beginners.yml b/examples/compose/docker-compose.beginners.yml index 9cacd4c95fc..eee0a697523 100644 --- a/examples/compose/docker-compose.beginners.yml +++ b/examples/compose/docker-compose.beginners.yml @@ -58,7 +58,7 @@ services: - "3306" vtctld: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15000:$WEB_PORT" - "$GRPC_PORT" @@ -81,7 +81,7 @@ services: condition: service_healthy vtgate: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15099:$WEB_PORT" - "$GRPC_PORT" @@ -111,7 +111,7 @@ services: condition: service_healthy schemaload: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 command: - sh - -c @@ -144,12 +144,12 @@ services: environment: - KEYSPACES=$KEYSPACE - GRPC_PORT=15999 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script vttablet100: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15100:$WEB_PORT" - "$GRPC_PORT" @@ -181,7 +181,7 @@ services: retries: 15 vttablet101: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15101:$WEB_PORT" - "$GRPC_PORT" @@ -213,7 +213,7 @@ services: retries: 15 vttablet102: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15102:$WEB_PORT" - "$GRPC_PORT" @@ -245,7 +245,7 @@ services: retries: 15 vttablet103: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15103:$WEB_PORT" - "$GRPC_PORT" @@ -277,7 +277,7 @@ services: retries: 15 vtorc: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 command: ["sh", "-c", "/script/vtorc-up.sh"] depends_on: - vtctld @@ -307,7 +307,7 @@ services: retries: 15 vreplication: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - ".:/script" environment: diff --git a/examples/compose/docker-compose.yml b/examples/compose/docker-compose.yml index 1e7914424f1..c0322bcff99 100644 --- a/examples/compose/docker-compose.yml +++ b/examples/compose/docker-compose.yml @@ -75,7 +75,7 @@ services: - SCHEMA_FILES=lookup_keyspace_schema_file.sql - POST_LOAD_FILE= - EXTERNAL_DB=0 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script schemaload_test_keyspace: @@ -101,7 +101,7 @@ services: - SCHEMA_FILES=test_keyspace_schema_file.sql - POST_LOAD_FILE= - EXTERNAL_DB=0 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script set_keyspace_durability_policy: @@ -115,7 +115,7 @@ services: environment: - KEYSPACES=test_keyspace lookup_keyspace - GRPC_PORT=15999 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script vreplication: @@ -129,7 +129,7 @@ services: - TOPOLOGY_FLAGS=--topo_implementation consul --topo_global_server_address consul1:8500 --topo_global_root vitess/global - EXTERNAL_DB=0 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script vtctld: @@ -143,7 +143,7 @@ services: depends_on: external_db_host: condition: service_healthy - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15000:8080 - "15999" @@ -160,7 +160,7 @@ services: --normalize_queries=true ' depends_on: - vtctld - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15099:8080 - "15999" @@ -182,7 +182,7 @@ services: - EXTERNAL_DB=0 - DB_USER= - DB_PASS= - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 13000:8080 volumes: @@ -217,7 +217,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15101:8080 - "15999" @@ -254,7 +254,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15102:8080 - "15999" @@ -291,7 +291,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15201:8080 - "15999" @@ -328,7 +328,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15202:8080 - "15999" @@ -365,7 +365,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15301:8080 - "15999" @@ -402,7 +402,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15302:8080 - "15999" diff --git a/examples/compose/vtcompose/docker-compose.test.yml b/examples/compose/vtcompose/docker-compose.test.yml index 11300c59975..96d9f80ffbd 100644 --- a/examples/compose/vtcompose/docker-compose.test.yml +++ b/examples/compose/vtcompose/docker-compose.test.yml @@ -79,7 +79,7 @@ services: - SCHEMA_FILES=test_keyspace_schema_file.sql - POST_LOAD_FILE= - EXTERNAL_DB=0 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script schemaload_unsharded_keyspace: @@ -103,7 +103,7 @@ services: - SCHEMA_FILES=unsharded_keyspace_schema_file.sql - POST_LOAD_FILE= - EXTERNAL_DB=0 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script set_keyspace_durability_policy_test_keyspace: @@ -117,7 +117,7 @@ services: environment: - GRPC_PORT=15999 - KEYSPACES=test_keyspace - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script set_keyspace_durability_policy_unsharded_keyspace: @@ -130,7 +130,7 @@ services: environment: - GRPC_PORT=15999 - KEYSPACES=unsharded_keyspace - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script vreplication: @@ -144,7 +144,7 @@ services: - TOPOLOGY_FLAGS=--topo_implementation consul --topo_global_server_address consul1:8500 --topo_global_root vitess/global - EXTERNAL_DB=0 - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - .:/script vtctld: @@ -159,7 +159,7 @@ services: depends_on: external_db_host: condition: service_healthy - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15000:8080 - "15999" @@ -176,7 +176,7 @@ services: ''grpc-vtgateservice'' --normalize_queries=true ' depends_on: - vtctld - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15099:8080 - "15999" @@ -199,7 +199,7 @@ services: - EXTERNAL_DB=0 - DB_USER= - DB_PASS= - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 13000:8080 volumes: @@ -234,7 +234,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15101:8080 - "15999" @@ -271,7 +271,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15102:8080 - "15999" @@ -308,7 +308,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15201:8080 - "15999" @@ -345,7 +345,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15202:8080 - "15999" @@ -382,7 +382,7 @@ services: - CMD-SHELL - curl -s --fail --show-error localhost:8080/debug/health timeout: 10s - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - 15301:8080 - "15999" diff --git a/examples/compose/vtcompose/vtcompose.go b/examples/compose/vtcompose/vtcompose.go index 62d8116b256..ee91d453892 100644 --- a/examples/compose/vtcompose/vtcompose.go +++ b/examples/compose/vtcompose/vtcompose.go @@ -533,7 +533,7 @@ func generateDefaultShard(tabAlias int, shard string, keyspaceData keyspaceInfo, - op: add path: /services/init_shard_primary%[2]d value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 command: ["sh", "-c", "/vt/bin/vtctldclient %[5]s InitShardPrimary --force %[4]s/%[3]s %[6]s-%[2]d "] %[1]s `, dependsOn, aliases[0], shard, keyspaceData.keyspace, opts.topologyFlags, opts.cell) @@ -565,7 +565,7 @@ func generateExternalPrimary( - op: add path: /services/vttablet%[1]d value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15%[1]d:%[3]d" - "%[4]d" @@ -627,7 +627,7 @@ func generateDefaultTablet(tabAlias int, shard, role, keyspace string, dbInfo ex - op: add path: /services/vttablet%[1]d value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15%[1]d:%[4]d" - "%[5]d" @@ -665,7 +665,7 @@ func generateVtctld(opts vtOptions) string { - op: add path: /services/vtctld value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15000:%[1]d" - "%[2]d" @@ -696,7 +696,7 @@ func generateVtgate(opts vtOptions) string { - op: add path: /services/vtgate value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 ports: - "15099:%[1]d" - "%[2]d" @@ -738,7 +738,7 @@ func generateVTOrc(dbInfo externalDbInfo, keyspaceInfoMap map[string]keyspaceInf - op: add path: /services/vtorc value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - ".:/script" environment: @@ -763,7 +763,7 @@ func generateVreplication(dbInfo externalDbInfo, opts vtOptions) string { - op: add path: /services/vreplication value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - ".:/script" environment: @@ -791,7 +791,7 @@ func generateSetKeyspaceDurabilityPolicy( - op: add path: /services/set_keyspace_durability_policy_%[3]s value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - ".:/script" environment: @@ -828,7 +828,7 @@ func generateSchemaload( - op: add path: /services/schemaload_%[7]s value: - image: vitess/lite:v18.0.5-shopify-4 + image: vitess/lite:v18.0.5-shopify-5 volumes: - ".:/script" environment: diff --git a/examples/operator/101_initial_cluster.yaml b/examples/operator/101_initial_cluster.yaml index 8ba575d9f2f..3dc5a7bfc5f 100644 --- a/examples/operator/101_initial_cluster.yaml +++ b/examples/operator/101_initial_cluster.yaml @@ -8,14 +8,14 @@ metadata: name: example spec: images: - vtctld: vitess/lite:v18.0.5-shopify-4 - vtadmin: vitess/vtadmin:v18.0.5-shopify-4 - vtgate: vitess/lite:v18.0.5-shopify-4 - vttablet: vitess/lite:v18.0.5-shopify-4 - vtbackup: vitess/lite:v18.0.5-shopify-4 - vtorc: vitess/lite:v18.0.5-shopify-4 + vtctld: vitess/lite:v18.0.5-shopify-5 + vtadmin: vitess/vtadmin:v18.0.5-shopify-5 + vtgate: vitess/lite:v18.0.5-shopify-5 + vttablet: vitess/lite:v18.0.5-shopify-5 + vtbackup: vitess/lite:v18.0.5-shopify-5 + vtorc: vitess/lite:v18.0.5-shopify-5 mysqld: - mysql80Compatible: vitess/lite:v18.0.5-shopify-4 + mysql80Compatible: vitess/lite:v18.0.5-shopify-5 mysqldExporter: prom/mysqld-exporter:v0.11.0 cells: - name: zone1 diff --git a/examples/operator/201_customer_tablets.yaml b/examples/operator/201_customer_tablets.yaml index 593c59bc86f..2eb4b996b93 100644 --- a/examples/operator/201_customer_tablets.yaml +++ b/examples/operator/201_customer_tablets.yaml @@ -4,14 +4,14 @@ metadata: name: example spec: images: - vtctld: vitess/lite:v18.0.5-shopify-4 - vtadmin: vitess/vtadmin:v18.0.5-shopify-4 - vtgate: vitess/lite:v18.0.5-shopify-4 - vttablet: vitess/lite:v18.0.5-shopify-4 - vtbackup: vitess/lite:v18.0.5-shopify-4 - vtorc: vitess/lite:v18.0.5-shopify-4 + vtctld: vitess/lite:v18.0.5-shopify-5 + vtadmin: vitess/vtadmin:v18.0.5-shopify-5 + vtgate: vitess/lite:v18.0.5-shopify-5 + vttablet: vitess/lite:v18.0.5-shopify-5 + vtbackup: vitess/lite:v18.0.5-shopify-5 + vtorc: vitess/lite:v18.0.5-shopify-5 mysqld: - mysql80Compatible: vitess/lite:v18.0.5-shopify-4 + mysql80Compatible: vitess/lite:v18.0.5-shopify-5 mysqldExporter: prom/mysqld-exporter:v0.11.0 cells: - name: zone1 diff --git a/examples/operator/302_new_shards.yaml b/examples/operator/302_new_shards.yaml index da58129bd48..cd5a3b9d267 100644 --- a/examples/operator/302_new_shards.yaml +++ b/examples/operator/302_new_shards.yaml @@ -4,14 +4,14 @@ metadata: name: example spec: images: - vtctld: vitess/lite:v18.0.5-shopify-4 - vtadmin: vitess/vtadmin:v18.0.5-shopify-4 - vtgate: vitess/lite:v18.0.5-shopify-4 - vttablet: vitess/lite:v18.0.5-shopify-4 - vtbackup: vitess/lite:v18.0.5-shopify-4 - vtorc: vitess/lite:v18.0.5-shopify-4 + vtctld: vitess/lite:v18.0.5-shopify-5 + vtadmin: vitess/vtadmin:v18.0.5-shopify-5 + vtgate: vitess/lite:v18.0.5-shopify-5 + vttablet: vitess/lite:v18.0.5-shopify-5 + vtbackup: vitess/lite:v18.0.5-shopify-5 + vtorc: vitess/lite:v18.0.5-shopify-5 mysqld: - mysql80Compatible: vitess/lite:v18.0.5-shopify-4 + mysql80Compatible: vitess/lite:v18.0.5-shopify-5 mysqldExporter: prom/mysqld-exporter:v0.11.0 cells: - name: zone1 diff --git a/examples/operator/306_down_shard_0.yaml b/examples/operator/306_down_shard_0.yaml index 7e4fb04b025..78c7a3e7355 100644 --- a/examples/operator/306_down_shard_0.yaml +++ b/examples/operator/306_down_shard_0.yaml @@ -4,14 +4,14 @@ metadata: name: example spec: images: - vtctld: vitess/lite:v18.0.5-shopify-4 - vtadmin: vitess/vtadmin:v18.0.5-shopify-4 - vtgate: vitess/lite:v18.0.5-shopify-4 - vttablet: vitess/lite:v18.0.5-shopify-4 - vtbackup: vitess/lite:v18.0.5-shopify-4 - vtorc: vitess/lite:v18.0.5-shopify-4 + vtctld: vitess/lite:v18.0.5-shopify-5 + vtadmin: vitess/vtadmin:v18.0.5-shopify-5 + vtgate: vitess/lite:v18.0.5-shopify-5 + vttablet: vitess/lite:v18.0.5-shopify-5 + vtbackup: vitess/lite:v18.0.5-shopify-5 + vtorc: vitess/lite:v18.0.5-shopify-5 mysqld: - mysql80Compatible: vitess/lite:v18.0.5-shopify-4 + mysql80Compatible: vitess/lite:v18.0.5-shopify-5 mysqldExporter: prom/mysqld-exporter:v0.11.0 cells: - name: zone1 diff --git a/go/mysql/conn.go b/go/mysql/conn.go index 6f3643ebc7f..5263d643df5 100644 --- a/go/mysql/conn.go +++ b/go/mysql/conn.go @@ -1707,7 +1707,6 @@ func (c *Conn) IsMarkedForClose() bool { return c.closing } -// GetTestConn returns a conn for testing purpose only. -func GetTestConn() *Conn { - return newConn(testConn{}) +func (c *Conn) IsShuttingDown() bool { + return c.listener.shutdown.Load() } diff --git a/go/mysql/conn_fake.go b/go/mysql/conn_fake.go index 72d944c2f3b..e61f90d33f1 100644 --- a/go/mysql/conn_fake.go +++ b/go/mysql/conn_fake.go @@ -81,3 +81,14 @@ func (m mockAddress) String() string { } var _ net.Addr = (*mockAddress)(nil) + +// GetTestConn returns a conn for testing purpose only. +func GetTestConn() *Conn { + return newConn(testConn{}) +} + +// GetTestServerConn is only meant to be used for testing. +// It creates a server connection using a testConn and the provided listener. +func GetTestServerConn(listener *Listener) *Conn { + return newServerConn(testConn{}, listener) +} diff --git a/go/vt/servenv/version.go b/go/vt/servenv/version.go index 9bb61e03525..3b014b11e12 100644 --- a/go/vt/servenv/version.go +++ b/go/vt/servenv/version.go @@ -19,4 +19,4 @@ package servenv // THIS FILE IS AUTO-GENERATED DURING NEW RELEASES BY ./tools/do_releases.sh // DO NOT EDIT -const versionName = "18.0.5-shopify-4" +const versionName = "18.0.5-shopify-5" diff --git a/go/vt/vtgate/plugin_mysql_server.go b/go/vt/vtgate/plugin_mysql_server.go index bfbb7b105f8..273592b5bf7 100644 --- a/go/vt/vtgate/plugin_mysql_server.go +++ b/go/vt/vtgate/plugin_mysql_server.go @@ -201,6 +201,12 @@ func startSpan(ctx context.Context, query, label string) (trace.Span, context.Co } func (vh *vtgateHandler) ComQuery(c *mysql.Conn, query string, callback func(*sqltypes.Result) error) error { + session := vh.session(c) + if c.IsShuttingDown() && !session.InTransaction { + c.MarkForClose() + return sqlerror.NewSQLError(sqlerror.ERServerShutdown, sqlerror.SSNetError, "Server shutdown in progress") + } + ctx, cancel := context.WithCancel(context.Background()) c.UpdateCancelCtx(cancel) @@ -229,7 +235,6 @@ func (vh *vtgateHandler) ComQuery(c *mysql.Conn, query string, callback func(*sq "VTGate MySQL Connector" /* subcomponent: part of the client */) ctx = callerid.NewContext(ctx, ef, im) - session := vh.session(c) if !session.InTransaction { vh.busyConnections.Add(1) } @@ -614,11 +619,11 @@ func newMysqlUnixSocket(address string, authServer mysql.AuthServer, handler mys func (srv *mysqlServer) shutdownMysqlProtocolAndDrain() { if srv.tcpListener != nil { - srv.tcpListener.Close() + srv.tcpListener.Shutdown() srv.tcpListener = nil } if srv.unixListener != nil { - srv.unixListener.Close() + srv.unixListener.Shutdown() srv.unixListener = nil } if srv.sigChan != nil { diff --git a/go/vt/vtgate/plugin_mysql_server_test.go b/go/vt/vtgate/plugin_mysql_server_test.go index 1b161dfb171..1aa201b5d4c 100644 --- a/go/vt/vtgate/plugin_mysql_server_test.go +++ b/go/vt/vtgate/plugin_mysql_server_test.go @@ -342,3 +342,80 @@ func TestKillMethods(t *testing.T) { require.EqualError(t, cancelCtx.Err(), "context canceled") require.True(t, mysqlConn.IsMarkedForClose()) } + +func TestGracefulShutdown(t *testing.T) { + executor, _, _, _, _ := createExecutorEnv(t) + + vh := newVtgateHandler(&VTGate{executor: executor, timings: timings, rowsReturned: rowsReturned, rowsAffected: rowsAffected}) + th := &testHandler{} + listener, err := mysql.NewListener("tcp", "127.0.0.1:", mysql.NewAuthServerNone(), th, 0, 0, false, false, 0) + require.NoError(t, err) + defer listener.Close() + + // add a connection + mysqlConn := mysql.GetTestServerConn(listener) + mysqlConn.ConnectionID = 1 + mysqlConn.UserData = &mysql.StaticUserData{} + vh.connections[1] = mysqlConn + + err = vh.ComQuery(mysqlConn, "select 1", func(result *sqltypes.Result) error { + return nil + }) + assert.NoError(t, err) + + listener.Shutdown() + + err = vh.ComQuery(mysqlConn, "select 1", func(result *sqltypes.Result) error { + return nil + }) + require.EqualError(t, err, "Server shutdown in progress (errno 1053) (sqlstate 08S01)") + + require.True(t, mysqlConn.IsMarkedForClose()) +} + +func TestGracefulShutdownWithTransaction(t *testing.T) { + executor, _, _, _, _ := createExecutorEnv(t) + + vh := newVtgateHandler(&VTGate{executor: executor, timings: timings, rowsReturned: rowsReturned, rowsAffected: rowsAffected}) + th := &testHandler{} + listener, err := mysql.NewListener("tcp", "127.0.0.1:", mysql.NewAuthServerNone(), th, 0, 0, false, false, 0) + require.NoError(t, err) + defer listener.Close() + + // add a connection + mysqlConn := mysql.GetTestServerConn(listener) + mysqlConn.ConnectionID = 1 + mysqlConn.UserData = &mysql.StaticUserData{} + vh.connections[1] = mysqlConn + + err = vh.ComQuery(mysqlConn, "BEGIN", func(result *sqltypes.Result) error { + return nil + }) + assert.NoError(t, err) + + err = vh.ComQuery(mysqlConn, "select 1", func(result *sqltypes.Result) error { + return nil + }) + assert.NoError(t, err) + + listener.Shutdown() + + err = vh.ComQuery(mysqlConn, "select 1", func(result *sqltypes.Result) error { + return nil + }) + assert.NoError(t, err) + + err = vh.ComQuery(mysqlConn, "COMMIT", func(result *sqltypes.Result) error { + return nil + }) + assert.NoError(t, err) + + require.False(t, mysqlConn.IsMarkedForClose()) + + err = vh.ComQuery(mysqlConn, "select 1", func(result *sqltypes.Result) error { + return nil + }) + require.EqualError(t, err, "Server shutdown in progress (errno 1053) (sqlstate 08S01)") + + require.True(t, mysqlConn.IsMarkedForClose()) +} diff --git a/java/client/pom.xml b/java/client/pom.xml index 516382f93dc..2c45899c402 100644 --- a/java/client/pom.xml +++ b/java/client/pom.xml @@ -5,7 +5,7 @@ io.vitess vitess-parent - 18.0.5-shopify-4 + 18.0.5-shopify-5 vitess-client diff --git a/java/example/pom.xml b/java/example/pom.xml index affb61263e9..ff667820ec1 100644 --- a/java/example/pom.xml +++ b/java/example/pom.xml @@ -5,7 +5,7 @@ io.vitess vitess-parent - 18.0.5-shopify-4 + 18.0.5-shopify-5 vitess-example diff --git a/java/grpc-client/pom.xml b/java/grpc-client/pom.xml index e67e34e730a..f2920306acf 100644 --- a/java/grpc-client/pom.xml +++ b/java/grpc-client/pom.xml @@ -5,7 +5,7 @@ io.vitess vitess-parent - 18.0.5-shopify-4 + 18.0.5-shopify-5 vitess-grpc-client diff --git a/java/jdbc/pom.xml b/java/jdbc/pom.xml index 77428b8169f..9630a1c69ba 100644 --- a/java/jdbc/pom.xml +++ b/java/jdbc/pom.xml @@ -5,7 +5,7 @@ io.vitess vitess-parent - 18.0.5-shopify-4 + 18.0.5-shopify-5 vitess-jdbc diff --git a/java/pom.xml b/java/pom.xml index 8c352753ec0..dec9e516f67 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -11,7 +11,7 @@ io.vitess vitess-parent - 18.0.5-shopify-4 + 18.0.5-shopify-5 pom Vitess Java Client libraries [Parent]