diff --git a/go/vt/discovery/healthcheck.go b/go/vt/discovery/healthcheck.go index d0469f44a54..fbc4994f0d2 100644 --- a/go/vt/discovery/healthcheck.go +++ b/go/vt/discovery/healthcheck.go @@ -288,7 +288,7 @@ func NewHealthCheck(ctx context.Context, retryDelay, healthCheckTimeout time.Dur var topoWatchers []*TopologyWatcher var filter TabletFilter cells := strings.Split(cellsToWatch, ",") - if len(cells) == 0 { + if cellsToWatch == "" { cells = append(cells, localCell) } for _, c := range cells { @@ -319,7 +319,7 @@ func NewHealthCheck(ctx context.Context, retryDelay, healthCheckTimeout time.Dur // start the topo watches here for _, tw := range hc.topoWatchers { - go tw.Start() + tw.Start() } return hc diff --git a/go/vt/discovery/topology_watcher.go b/go/vt/discovery/topology_watcher.go index 6cfc1ffcba0..3c40fce30e6 100644 --- a/go/vt/discovery/topology_watcher.go +++ b/go/vt/discovery/topology_watcher.go @@ -125,17 +125,19 @@ func NewCellTabletsWatcher(ctx context.Context, topoServer *topo.Server, tr Tabl // Start starts the topology watcher func (tw *TopologyWatcher) Start() { tw.wg.Add(1) - defer tw.wg.Done() - ticker := time.NewTicker(tw.refreshInterval) - defer ticker.Stop() - for { - tw.loadTablets() - select { - case <-tw.ctx.Done(): - return - case <-ticker.C: + go func() { + defer tw.wg.Done() + ticker := time.NewTicker(tw.refreshInterval) + defer ticker.Stop() + for { + tw.loadTablets() + select { + case <-tw.ctx.Done(): + return + case <-ticker.C: + } } - } + }() } // Stop stops the watcher. It does not clean up the tablets added to LegacyTabletRecorder. diff --git a/go/vt/vtgate/tabletgateway_test.go b/go/vt/vtgate/tabletgateway_test.go index 48e0e32e2d8..58cca3dd823 100644 --- a/go/vt/vtgate/tabletgateway_test.go +++ b/go/vt/vtgate/tabletgateway_test.go @@ -107,7 +107,8 @@ func TestTabletGatewayBeginExecuteBatch(t *testing.T) { } func TestTabletGatewayShuffleTablets(t *testing.T) { - tg := NewTabletGateway(context.Background(), nil, nil, "local") + hc := discovery.NewFakeHealthCheck(nil) + tg := NewTabletGateway(context.Background(), hc, nil, "local") ts1 := &discovery.TabletHealth{ Tablet: topo.NewTablet(1, "cell1", "host1"),