Skip to content

Commit

Permalink
Init map while initing stats
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Jan 28, 2025
1 parent 34957f9 commit c4476e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
14 changes: 1 addition & 13 deletions go/vt/vttablet/tabletmanager/vdiff/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ func (vde *Engine) openLocked(ctx context.Context) error {
if err != nil {
return err
}

vde.ctx, vde.cancel = context.WithCancel(ctx)
vde.isOpen = true // now we are open and have things to close
if err := vde.initControllers(rows); err != nil {
return err
}
vde.updateStats()

// At this point we've fully and successfully opened so begin
// retrying error'd VDiffs until the engine is closed.
Expand Down Expand Up @@ -400,16 +400,4 @@ func (vde *Engine) resetControllers() {
ct.Stop()
}
vde.controllers = make(map[int64]*controller)
vde.updateStats()
}

// updateStats must only be called while holding the engine lock.
func (vre *Engine) updateStats() {
globalStats.mu.Lock()
defer globalStats.mu.Unlock()

globalStats.controllers = make(map[int64]*controller, len(vre.controllers))
for id, ct := range vre.controllers {
globalStats.controllers[id] = ct
}
}
1 change: 1 addition & 0 deletions go/vt/vttablet/tabletmanager/vdiff/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (vds *vdiffStats) register() {
globalStats.ErrorCount = stats.NewCounter("", "")
globalStats.RestartedTableDiffs = stats.NewCountersWithSingleLabel("", "", "Table")
globalStats.RowsDiffedCount = stats.NewCounter("", "")
globalStats.controllers = make(map[int64]*controller)

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

Expand Down

0 comments on commit c4476e5

Please sign in to comment.