Skip to content

Commit

Permalink
count tablets post-match
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Mar 6, 2025
1 parent 596dfde commit c861fa2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions go/vt/vtorc/logic/tablet_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func getAllTablets(ctx context.Context, cells []string) (tabletsByCell map[strin
var mu sync.Mutex
failedCells = make([]string, 0, len(cells))
tabletsByCell = make(map[string][]*topo.TabletInfo, len(cells))
newTabletsWatchedByCell := make(map[string]int64)
eg, ctx := errgroup.WithContext(ctx)
for _, cell := range cells {
eg.Go(func() error {
Expand All @@ -179,13 +178,11 @@ func getAllTablets(ctx context.Context, cells []string) (tabletsByCell map[strin
failedCells = append(failedCells, cell)
} else {
tabletsByCell[cell] = tablets
newTabletsWatchedByCell[cell] = int64(len(tablets))
}
return nil
})
}
_ = eg.Wait() // always nil
tabletsWatchedByCell = newTabletsWatchedByCell
return tabletsByCell, failedCells
}

Expand Down Expand Up @@ -220,6 +217,7 @@ func refreshTabletsUsing(ctx context.Context, loader func(tabletAlias string), f

// Update each cell that provided a response. This ensures only cells that provided a
// response are updated in the backend and are considered for forgetting stale tablets.
newTabletsWatchedByCell := make(map[string]int64)
for cell, tablets := range tabletsByCell {
// Filter tablets that should not be watched using func shouldWatchTablet.
matchedTablets := make([]*topo.TabletInfo, 0, len(tablets))
Expand All @@ -235,7 +233,10 @@ func refreshTabletsUsing(ctx context.Context, loader func(tabletAlias string), f
query := "select alias from vitess_tablet where cell = ?"
args := sqlutils.Args(cell)
refreshTablets(matchedTablets, query, args, loader, forceRefresh, nil)

newTabletsWatchedByCell[cell] = int64(len(matchedTablets))
}
tabletsWatchedByCell = newTabletsWatchedByCell

return nil
}
Expand Down

0 comments on commit c861fa2

Please sign in to comment.