diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 1cf1a78ee7d..48cbd6fddec 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -1032,7 +1032,7 @@ func commandRefreshStateByShard(ctx context.Context, wr *wrangler.Wrangler, subF if *cellsStr != "" { cells = strings.Split(*cellsStr, ",") } - return wr.RefreshTabletsByShard(ctx, si, nil /* tabletTypes */, cells) + return wr.RefreshTabletsByShard(ctx, si, cells) } func commandRunHealthCheck(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { diff --git a/go/vt/wrangler/keyspace.go b/go/vt/wrangler/keyspace.go index e2292972e1f..6ecd1b1d774 100644 --- a/go/vt/wrangler/keyspace.go +++ b/go/vt/wrangler/keyspace.go @@ -379,7 +379,7 @@ func (wr *Wrangler) cancelHorizontalResharding(ctx context.Context, keyspace, sh destinationShards[i] = updatedShard - if err := wr.RefreshTabletsByShard(ctx, si, nil, nil); err != nil { + if err := wr.RefreshTabletsByShard(ctx, si, nil); err != nil { return err } } @@ -450,6 +450,8 @@ func (wr *Wrangler) MigrateServedTypes(ctx context.Context, keyspace, shard stri // refresh // TODO(b/26388813): Integrate vtctl WaitForDrain here instead of just sleeping. // Anything that's not a replica will use the RDONLY sleep time. + // Master Migrate performs its own refresh but we will refresh all non master + // tablets after each migration waitForDrainSleep := *waitForDrainSleepRdonly if servedType == topodatapb.TabletType_REPLICA { waitForDrainSleep = *waitForDrainSleepReplica @@ -465,7 +467,7 @@ func (wr *Wrangler) MigrateServedTypes(ctx context.Context, keyspace, shard stri refreshShards = destinationShards } for _, si := range refreshShards { - rec.RecordError(wr.RefreshTabletsByShard(ctx, si, []topodatapb.TabletType{servedType}, cells)) + rec.RecordError(wr.RefreshTabletsByShard(ctx, si, cells)) } return rec.Error() } @@ -813,6 +815,12 @@ func (wr *Wrangler) masterMigrateServedType(ctx context.Context, keyspace string } } + for _, si := range destinationShards { + if err := wr.RefreshTabletsByShard(ctx, si, nil); err != nil { + return err + } + } + event.DispatchUpdate(ev, "finished") return nil } @@ -932,7 +940,7 @@ func (wr *Wrangler) updateShardRecords(ctx context.Context, keyspace string, sha // For 'to' shards, refresh to make them serve. // The 'from' shards will be refreshed after traffic has migrated. if !isFrom { - wr.RefreshTabletsByShard(ctx, si, []topodatapb.TabletType{servedType}, cells) + wr.RefreshTabletsByShard(ctx, si, cells) } } return nil @@ -1268,7 +1276,7 @@ func (wr *Wrangler) replicaMigrateServedFrom(ctx context.Context, ki *topo.Keysp // Now refresh the source servers so they reload their // blacklisted table list event.DispatchUpdate(ev, "refreshing sources tablets state so they update their blacklisted tables") - return wr.RefreshTabletsByShard(ctx, sourceShard, []topodatapb.TabletType{servedType}, cells) + return wr.RefreshTabletsByShard(ctx, sourceShard, cells) } // masterMigrateServedFrom handles the master migration. The ordering is @@ -1374,10 +1382,8 @@ func (wr *Wrangler) SetKeyspaceServedFrom(ctx context.Context, keyspace string, return wr.ts.UpdateKeyspace(ctx, ki) } -// RefreshTabletsByShard calls RefreshState on all the tables of a -// given type in a shard. It would work for the master, but the -// discovery wouldn't be very efficient. -func (wr *Wrangler) RefreshTabletsByShard(ctx context.Context, si *topo.ShardInfo, tabletTypes []topodatapb.TabletType, cells []string) error { +// RefreshTabletsByShard calls RefreshState on all the tablets in a given shard. +func (wr *Wrangler) RefreshTabletsByShard(ctx context.Context, si *topo.ShardInfo, cells []string) error { wr.Logger().Infof("RefreshTabletsByShard called on shard %v/%v", si.Keyspace(), si.ShardName()) tabletMap, err := wr.ts.GetTabletMapForShardByCell(ctx, si.Keyspace(), si.ShardName(), cells) switch { @@ -1392,9 +1398,6 @@ func (wr *Wrangler) RefreshTabletsByShard(ctx context.Context, si *topo.ShardInf // ignore errors in this phase wg := sync.WaitGroup{} for _, ti := range tabletMap { - if tabletTypes != nil && !topoproto.IsTypeInList(ti.Type, tabletTypes) { - continue - } if ti.Hostname == "" { // The tablet is not running, we don't have the host // name to connect to, so we just skip this tablet. diff --git a/go/vt/wrangler/traffic_switcher.go b/go/vt/wrangler/traffic_switcher.go index 461311ac1bd..240e363187c 100644 --- a/go/vt/wrangler/traffic_switcher.go +++ b/go/vt/wrangler/traffic_switcher.go @@ -1129,7 +1129,7 @@ func (ts *trafficSwitcher) changeTableSourceWrites(ctx context.Context, access a }); err != nil { return err } - return ts.wr.RefreshTabletsByShard(ctx, source.si, nil, nil) + return ts.wr.RefreshTabletsByShard(ctx, source.si, nil) }) } @@ -1364,7 +1364,7 @@ func (ts *trafficSwitcher) allowTableTargetWrites(ctx context.Context) error { }); err != nil { return err } - return ts.wr.RefreshTabletsByShard(ctx, target.si, nil, nil) + return ts.wr.RefreshTabletsByShard(ctx, target.si, nil) }) } @@ -1522,7 +1522,7 @@ func (ts *trafficSwitcher) dropSourceBlacklistedTables(ctx context.Context) erro }); err != nil { return err } - return ts.wr.RefreshTabletsByShard(ctx, source.si, nil, nil) + return ts.wr.RefreshTabletsByShard(ctx, source.si, nil) }) }