Skip to content

Commit

Permalink
Changes from self review
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Jan 14, 2025
1 parent 269d30b commit 0d3cc67
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func TestRoutingWithKeyspacesToWatch(t *testing.T) {
}

func TestVSchemaDDLWithKeyspacesToWatch(t *testing.T) {

extraVTGateArgs := []string{
"--vschema_ddl_authorized_users", "%",
}
Expand Down
5 changes: 3 additions & 2 deletions go/test/endtoend/vtgate/vschema/vschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -210,15 +211,15 @@ 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 {
require.NoError(t, err)
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)
Expand Down
8 changes: 2 additions & 6 deletions go/vt/topo/srv_vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
}
}

Expand Down
3 changes: 2 additions & 1 deletion go/vt/vtgate/executorcontext/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down

0 comments on commit 0d3cc67

Please sign in to comment.