diff --git a/go/test/endtoend/vtgate/keyspace_watches/keyspace_watch_test.go b/go/test/endtoend/vtgate/keyspace_watches/keyspace_watch_test.go index d7ccbb1b0b9..1eb31663577 100644 --- a/go/test/endtoend/vtgate/keyspace_watches/keyspace_watch_test.go +++ b/go/test/endtoend/vtgate/keyspace_watches/keyspace_watch_test.go @@ -140,6 +140,7 @@ func TestRoutingWithKeyspacesToWatch(t *testing.T) { } func TestVSchemaDDLWithKeyspacesToWatch(t *testing.T) { + extraVTGateArgs := []string{ "--vschema_ddl_authorized_users", "%", } diff --git a/go/test/endtoend/vtgate/vschema/vschema_test.go b/go/test/endtoend/vtgate/vschema/vschema_test.go index bc1bf896931..885697696aa 100644 --- a/go/test/endtoend/vtgate/vschema/vschema_test.go +++ b/go/test/endtoend/vtgate/vschema/vschema_test.go @@ -35,6 +35,7 @@ import ( "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/test/endtoend/cluster" "vitess.io/vitess/go/test/endtoend/utils" + "vitess.io/vitess/go/vt/vtgate" ) var ( @@ -210,7 +211,7 @@ func TestVSchemaSQLAPIConcurrency(t *testing.T) { _, err = mysqlConns[i].ExecuteFetch(fmt.Sprintf("ALTER VSCHEMA ADD TABLE %s", tableName), -1, false) if err != nil { // The error we get is an SQL error so we have to do string matching. - if err != nil && strings.Contains(err.Error(), "failed to update vschema as the session's version was stale") { + if err != nil && strings.Contains(err.Error(), vtgate.ErrStaleVSchema.Error()) { preventedLostWrites = true } } else { @@ -218,7 +219,7 @@ func TestVSchemaSQLAPIConcurrency(t *testing.T) { time.Sleep(time.Duration(rand.Intn(1000) * int(time.Nanosecond))) _, err = mysqlConns[i].ExecuteFetch(fmt.Sprintf("ALTER VSCHEMA DROP TABLE %s", tableName), -1, false) // The error we get is an SQL error so we have to do string matching. - if err != nil && strings.Contains(err.Error(), "failed to update vschema as the session's version was stale") { + if err != nil && strings.Contains(err.Error(), vtgate.ErrStaleVSchema.Error()) { preventedLostWrites = true } else { require.NoError(t, err) diff --git a/go/vt/topo/srv_vschema.go b/go/vt/topo/srv_vschema.go index 909a5337919..e698c4f8851 100644 --- a/go/vt/topo/srv_vschema.go +++ b/go/vt/topo/srv_vschema.go @@ -175,12 +175,8 @@ func (ts *Server) RebuildSrvVSchema(ctx context.Context, cells []string) error { if IsErrType(err, NoNode) { err = nil ksvs = &KeyspaceVSchemaInfo{ - Name: keyspace, - Keyspace: &vschemapb.Keyspace{ - Sharded: false, - Vindexes: make(map[string]*vschemapb.Vindex), - Tables: make(map[string]*vschemapb.Table), - }, + Name: keyspace, + Keyspace: &vschemapb.Keyspace{}, } } diff --git a/go/vt/vtgate/executorcontext/vcursor_impl.go b/go/vt/vtgate/executorcontext/vcursor_impl.go index fb8eac5a7d6..5acb132332e 100644 --- a/go/vt/vtgate/executorcontext/vcursor_impl.go +++ b/go/vt/vtgate/executorcontext/vcursor_impl.go @@ -1406,7 +1406,8 @@ func (vc *VCursorImpl) ExecuteVSchema(ctx context.Context, keyspace string, vsch return err } } else { - // Use the cached version. + // Use the cached version as we are in read-only mode + // and any writes would fail. ksvs.Name = ksName ksvs.Keyspace = srvVschema.Keyspaces[ksName] }