Skip to content

Commit

Permalink
Merge pull request #7505 from planetscale/rn-movetables-refresh-routi…
Browse files Browse the repository at this point in the history
…ng-rules

MoveTables: Refresh SrvVSchema (for Routing Rules) and source tablets (for Blacklisted Tables) on completion
  • Loading branch information
rohit-nayak-ps authored Feb 19, 2021
2 parents b40fe32 + 275e4c8 commit 83b7408
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 83b7408

Please sign in to comment.