diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index ef3f2945ba2..d96636b34eb 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -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 { diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index 5e46fd66f85..ff03c1bfd59 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -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 {