Skip to content

Commit

Permalink
Remove obsolete comment. Reinit controller stats on engine open
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed Feb 4, 2025
1 parent 853bb6f commit 2cdeec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion go/vt/vttablet/tabletmanager/vdiff/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ func (vde *Engine) openLocked(ctx context.Context) error {
vde.resetControllers()
}

globalStats.initControllerStats()

// At this point the tablet has no controllers running. So
// we want to start any VDiffs that have not been explicitly
// stopped or otherwise finished.
Expand Down Expand Up @@ -222,7 +224,6 @@ func (vde *Engine) addController(row sqltypes.RowNamedValues, options *tabletman
defer globalStats.mu.Unlock()
globalStats.controllers[ct.id] = ct

// run() can start a vdiff in pending/started state, so we should init the stats first before starting it.
controllerCtx, cancel := context.WithCancel(vde.ctx)
ct.cancel = cancel
go ct.run(controllerCtx)
Expand Down
8 changes: 7 additions & 1 deletion go/vt/vttablet/tabletmanager/vdiff/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ type vdiffStats struct {
RowsDiffedCount *stats.Counter
}

func (vds *vdiffStats) initControllerStats() {
vds.mu.Lock()
defer vds.mu.Unlock()
vds.controllers = make(map[int64]*controller)
}

func (vds *vdiffStats) register() {
globalStats.Count = stats.NewGauge("", "")
globalStats.ErrorCount = stats.NewCounter("", "")
globalStats.RestartedTableDiffs = stats.NewCountersWithSingleLabel("", "", "Table")
globalStats.RowsDiffedCount = stats.NewCounter("", "")
globalStats.controllers = make(map[int64]*controller)
globalStats.initControllerStats()

stats.NewGaugeFunc("VDiffCount", "Number of current vdiffs", vds.numControllers)

Expand Down

0 comments on commit 2cdeec5

Please sign in to comment.