-
Notifications
You must be signed in to change notification settings - Fork 6k
br: concurrently set tiflash replicas #63360
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1504,6 +1504,28 @@ func WrapLogFilesIterWithCheckpointFailpoint( | |
return logIter, nil | ||
} | ||
|
||
// ResetTiflashReplicas set tiflash replicas by given sqls concurrently. | ||
func (rc *LogClient) ResetTiflashReplicas(ctx context.Context, sqls []string, g glue.Glue) error { | ||
resetSessions, err := createSessions(ctx, g, rc.dom.Store(), 16) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
defer func() { | ||
closeSessions(resetSessions) | ||
}() | ||
workerpool := tidbutil.NewWorkerPool(16, "repair ingest index") | ||
eg, ectx := errgroup.WithContext(ctx) | ||
for _, sql := range sqls { | ||
resetSQL := sql | ||
workerpool.ApplyWithIDInErrorGroup(eg, func(id uint64) error { | ||
resetSession := resetSessions[id%uint64(len(resetSessions))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems |
||
log.Info("reset tiflash replica", zap.String("sql", sql)) | ||
return resetSession.ExecuteInternal(ectx, resetSQL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If one SQL fails, should we continue to execute rest of them? |
||
}) | ||
} | ||
return eg.Wait() | ||
} | ||
|
||
func colsToStr(cols []ast.CIStr) string { | ||
var str strings.Builder | ||
for i, col := range cols { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember in our go version, we can directly use
sql
in for-loophttps://go.dev/blog/loopvar-preview