Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init map while initing stats
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
rohit-nayak-ps committed Jan 29, 2025

Verified

This commit was signed with the committer’s verified signature.
rohit-nayak-ps Rohit Nayak
1 parent e0cc801 commit ff0279f
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
@@ -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.
@@ -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
@@ -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)

0 comments on commit ff0279f

Please sign in to comment.