Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ func (e *Executor) handleShow(ctx context.Context, session *vtgatepb.Session, sq
for _, keyspace := range keyspaces {
_, _, shards, err := getKeyspaceShards(ctx, e.serv, e.cell, keyspace, target.TabletType)
if err != nil {
return nil, err
// There might be a misconfigured keyspace or no shards in the keyspace.
// Skip any errors and move on.
continue
}

for _, shard := range shards {
Expand Down
20 changes: 20 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,26 @@ func TestExecutorShow(t *testing.T) {
t.Errorf("show databases:\n%+v, want\n%+v", qr, wantqr)
}

// Make sure it still works when one of the keyspaces is in a bad state
getSandbox("TestExecutor").SrvKeyspaceMustFail++
qr, err = executor.Execute(context.Background(), session, "show vitess_shards", nil)
if err != nil {
t.Error(err)
}
// Just test for first & last.
qr.Rows = [][]sqltypes.Value{qr.Rows[0], qr.Rows[len(qr.Rows)-1]}
wantqr = &sqltypes.Result{
Fields: buildVarCharFields("Shards"),
Rows: [][]sqltypes.Value{
buildVarCharRow("TestSharded/-20"),
buildVarCharRow("TestXBadSharding/e0-"),
},
RowsAffected: 17,
}
if !reflect.DeepEqual(qr, wantqr) {
t.Errorf("show databases:\n%+v, want\n%+v", qr, wantqr)
}

session = &vtgatepb.Session{TargetString: KsTestUnsharded}
qr, err = executor.Execute(context.Background(), session, "show vschema_tables", nil)
if err != nil {
Expand Down