Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VDiff: fix race when a vdiff resumes on vttablet restart #17638

Merged
merged 5 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Init map while initing stats
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed Jan 29, 2025
commit ff0279f5375a5fc5c9147486fbed26830058ebed
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)