Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GetSchema filtering to exclude shards where IsMasterServing but no MasterAlias #7805

Merged
merged 2 commits into from
Apr 8, 2021
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
40 changes: 40 additions & 0 deletions go/vt/vtadmin/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,21 @@ func TestFindSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 100,
},
},
},
"80-": {
Keyspace: "testkeyspace",
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 200,
},
},
},
},
Expand All @@ -577,6 +585,10 @@ func TestFindSchema(t *testing.T) {
Name: "-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 300,
},
},
},
},
Expand Down Expand Up @@ -668,6 +680,10 @@ func TestFindSchema(t *testing.T) {
Name: "-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c2z1",
Uid: 100,
},
},
},
},
Expand Down Expand Up @@ -1403,13 +1419,21 @@ func TestGetSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 100,
},
},
},
"80-": {
Keyspace: "testkeyspace",
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 200,
},
},
},
},
Expand Down Expand Up @@ -2073,13 +2097,21 @@ func TestGetSchemas(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 100,
},
},
},
"80-": {
Keyspace: "testkeyspace",
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone1",
Uid: 200,
},
},
},
},
Expand All @@ -2093,6 +2125,10 @@ func TestGetSchemas(t *testing.T) {
Name: "-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c1zone2",
Uid: 100,
},
},
},
},
Expand Down Expand Up @@ -2184,6 +2220,10 @@ func TestGetSchemas(t *testing.T) {
Name: "-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "c2z1",
Uid: 100,
},
},
},
},
Expand Down
7 changes: 6 additions & 1 deletion go/vt/vtadmin/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,12 @@ func (c *Cluster) getTabletsToQueryForSchemas(ctx context.Context, keyspace stri
tabletsToQuery := make([]*vtadminpb.Tablet, 0, len(shards))

for _, shard := range shards {
if !shard.Shard.IsMasterServing {
// In certain setups, empty but "serving" shards may required to
// provide a contiguous keyspace so that certain keyspace-level
// operations will work. In our case, we care about whether the
// shard is truly serving, which we define as also having a known
// primary (via MasterAlias) in addition to the IsMasterServing bit.
if !(shard.Shard.IsMasterServing && shard.Shard.MasterAlias != nil) {
rafael marked this conversation as resolved.
Show resolved Hide resolved
log.Infof("%s/%s is not serving; ignoring ...", keyspace, shard.Name)
continue
}
Expand Down
40 changes: 40 additions & 0 deletions go/vt/vtadmin/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,20 @@ func TestGetSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
},
},
"80-": {
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
},
},
"-": {
Expand Down Expand Up @@ -769,12 +777,20 @@ func TestGetSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
},
},
"80-": {
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
},
},
"-": {
Expand Down Expand Up @@ -876,12 +892,20 @@ func TestGetSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
},
},
"80-": {
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
},
},
"-": {
Expand Down Expand Up @@ -1016,12 +1040,20 @@ func TestGetSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
},
},
"80-": {
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
},
},
"-": {
Expand Down Expand Up @@ -1197,12 +1229,20 @@ func TestGetSchema(t *testing.T) {
Name: "-80",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
},
},
"80-": {
Name: "80-",
Shard: &topodatapb.Shard{
IsMasterServing: true,
MasterAlias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
},
},
},
Expand Down