-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
domain: support plan replayer dump workers running in concurrency #39347
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
42ad0d6
support
Yisaer 3946c7e
support
Yisaer f7efd5e
support
Yisaer 227345b
support
Yisaer d002af8
support
Yisaer 94b8373
add log
Yisaer 630fab2
fix
Yisaer 3a908f9
fix
Yisaer 164f958
fix stats
Yisaer dd20da9
fix
Yisaer c42bcc8
Merge branch 'master' into support_multi_dump_worker
ti-chi-bot d54ede0
Merge branch 'master' into support_multi_dump_worker
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1573,17 +1573,31 @@ func (do *Domain) TelemetryRotateSubWindowLoop(ctx sessionctx.Context) { | |
} | ||
|
||
// SetupPlanReplayerHandle setup plan replayer handle | ||
func (do *Domain) SetupPlanReplayerHandle(collectorSctx, dumperSctx sessionctx.Context) { | ||
func (do *Domain) SetupPlanReplayerHandle(collectorSctx sessionctx.Context, workersSctxs []sessionctx.Context) { | ||
ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnStats) | ||
do.planReplayerHandle = &planReplayerHandle{} | ||
do.planReplayerHandle.planReplayerTaskCollectorHandle = &planReplayerTaskCollectorHandle{ | ||
ctx: ctx, | ||
sctx: collectorSctx, | ||
} | ||
taskCH := make(chan *PlanReplayerDumpTask, 16) | ||
taskStatus := &planReplayerDumpTaskStatus{} | ||
taskStatus.finishedTaskMu.finishedTask = map[PlanReplayerTaskKey]struct{}{} | ||
taskStatus.runningTaskMu.runningTasks = map[PlanReplayerTaskKey]struct{}{} | ||
|
||
do.planReplayerHandle.planReplayerTaskDumpHandle = &planReplayerTaskDumpHandle{ | ||
ctx: ctx, | ||
sctx: dumperSctx, | ||
taskCH: make(chan *PlanReplayerDumpTask, 16), | ||
taskCH: taskCH, | ||
status: taskStatus, | ||
} | ||
do.planReplayerHandle.planReplayerTaskDumpHandle.workers = make([]*planReplayerTaskDumpWorker, 0) | ||
for i := 0; i < len(workersSctxs); i++ { | ||
worker := &planReplayerTaskDumpWorker{ | ||
ctx: ctx, | ||
sctx: workersSctxs[i], | ||
taskCH: taskCH, | ||
status: taskStatus, | ||
} | ||
do.planReplayerHandle.planReplayerTaskDumpHandle.workers = append(do.planReplayerHandle.planReplayerTaskDumpHandle.workers, worker) | ||
} | ||
} | ||
|
||
|
@@ -1598,6 +1612,7 @@ func (do *Domain) SetupHistoricalStatsWorker(ctx sessionctx.Context) { | |
// SetupDumpFileGCChecker setup sctx | ||
func (do *Domain) SetupDumpFileGCChecker(ctx sessionctx.Context) { | ||
do.dumpFileGcChecker.setupSctx(ctx) | ||
do.dumpFileGcChecker.planReplayerTaskStatus = do.planReplayerHandle.status | ||
} | ||
|
||
var planReplayerHandleLease atomic.Uint64 | ||
|
@@ -1650,14 +1665,11 @@ func (do *Domain) StartPlanReplayerHandle() { | |
logutil.BgLogger().Info("PlanReplayerTaskDumpHandle exited.") | ||
util.Recover(metrics.LabelDomain, "PlanReplayerTaskDumpHandle", nil, false) | ||
}() | ||
for { | ||
select { | ||
case <-do.exit: | ||
return | ||
case task := <-do.planReplayerHandle.planReplayerTaskDumpHandle.taskCH: | ||
do.planReplayerHandle.HandlePlanReplayerDumpTask(task) | ||
} | ||
for _, worker := range do.planReplayerHandle.planReplayerTaskDumpHandle.workers { | ||
go worker.run() | ||
} | ||
<-do.exit | ||
do.planReplayerHandle.planReplayerTaskDumpHandle.Close() | ||
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. Do we need to also put 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. updated. |
||
}() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How about using a SQL variable instead of a config item? SQL variables are much easier to use.
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.
we can't adjust worker count in runtime thus we use config.