Skip to content

Commit

Permalink
Rebuild SrvVSchema after deleting routing rules on MoveTables complet…
Browse files Browse the repository at this point in the history
…ion/cancellation

This is a combination of 4 commits.
This is the commit message #2:

Check that routing rules are deleted in unit test

This is the commit message #3:

Fix typo

This is the commit message #4:

Refresh all tablets in a shard when updating blacklisted tables

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
rohit-nayak-ps authored and systay committed May 6, 2021
1 parent 3bce5f8 commit 3529118
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
13 changes: 10 additions & 3 deletions go/vt/wrangler/traffic_switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ func (wr *Wrangler) DropTargets(ctx context.Context, targetKeyspace, workflow st
if err := wr.dropArtifacts(ctx, sw); err != nil {
return nil, err
}
if err := ts.wr.ts.RebuildSrvVSchema(ctx, nil); err != nil {
return nil, err
}
return sw.logs(), nil
}

Expand Down Expand Up @@ -750,6 +753,10 @@ func (wr *Wrangler) DropSources(ctx context.Context, targetKeyspace, workflow st
if err := wr.dropArtifacts(ctx, sw); err != nil {
return nil, err
}
if err := ts.wr.ts.RebuildSrvVSchema(ctx, nil); err != nil {
return nil, err
}

return sw.logs(), nil
}

Expand Down Expand Up @@ -1102,7 +1109,7 @@ func (ts *trafficSwitcher) changeTableSourceWrites(ctx context.Context, access a
}); err != nil {
return err
}
return ts.wr.tmc.RefreshState(ctx, source.master.Tablet)
return ts.wr.RefreshTabletsByShard(ctx, source.si, nil, nil)
})
}

Expand Down Expand Up @@ -1337,7 +1344,7 @@ func (ts *trafficSwitcher) allowTableTargetWrites(ctx context.Context) error {
}); err != nil {
return err
}
return ts.wr.tmc.RefreshState(ctx, target.master.Tablet)
return ts.wr.RefreshTabletsByShard(ctx, target.si, nil, nil)
})
}

Expand Down Expand Up @@ -1481,7 +1488,7 @@ func (ts *trafficSwitcher) dropSourceBlacklistedTables(ctx context.Context) erro
}); err != nil {
return err
}
return ts.wr.tmc.RefreshState(ctx, source.master.Tablet)
return ts.wr.RefreshTabletsByShard(ctx, source.si, nil, nil)
})
}

Expand Down
20 changes: 19 additions & 1 deletion go/vt/wrangler/traffic_switcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,10 +915,28 @@ func TestTableMigrateOneToMany(t *testing.T) {
}
dropSources()

checkRouting(t, tme.wr, map[string][]string{
"t1": {"ks2.t1"},
"ks1.t1": {"ks2.t1"},
"t2": {"ks2.t2"},
"ks1.t2": {"ks2.t2"},
"t1@replica": {"ks2.t1"},
"ks2.t1@replica": {"ks2.t1"},
"ks1.t1@replica": {"ks2.t1"},
"t2@replica": {"ks2.t2"},
"ks2.t2@replica": {"ks2.t2"},
"ks1.t2@replica": {"ks2.t2"},
"t1@rdonly": {"ks2.t1"},
"ks2.t1@rdonly": {"ks2.t1"},
"ks1.t1@rdonly": {"ks2.t1"},
"t2@rdonly": {"ks2.t2"},
"ks2.t2@rdonly": {"ks2.t2"},
"ks1.t2@rdonly": {"ks2.t2"},
})
_, err = tme.wr.DropSources(ctx, tme.targetKeyspace, "test", RenameTable, false, false, false)
require.NoError(t, err)
checkBlacklist(t, tme.ts, fmt.Sprintf("%s:%s", "ks1", "0"), nil)

checkRouting(t, tme.wr, map[string][]string{})
verifyQueries(t, tme.allDBClients)
}

Expand Down

0 comments on commit 3529118

Please sign in to comment.