-
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
lightning: generate and send region job more smoothly #42780
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
|
||
func (local *local) doImport(ctx context.Context, engine *Engine, regionRanges []Range, regionSplitSize, regionSplitKeys int64) error { | ||
/* | ||
[prepareAndSendJob]-----jobToWorkerCh--->[workers] |
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.
@gozssky Can you give some suggestions on the pattern? Currently regionJob has different stages, multiple workers hold the resouces (pd client, ...) that can advance the stage, and producer/consumer are communicated by channel
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 can think of two design patterns
one is using goroutines to acquire "worker resource" and then start job, when the job need to sleep some period to retry, release the worker resource. like
for _, j := range jobs {
w := workerPool.Acquire()
go func() {j.run(w); w.Release()}
}
and
// when meet error
j.w.Release()
sleep()
j.w := workerPool.Acquire()
In this method, I want to rely on golang's goroutine scheduling to keep N system thread where N is worker count. But I'm afraid we will spawn too many sleeping goroutines and affect the runtime.
In the refactoring PR I want to do manually scheduling, where try to keep the N worker goroutines always busy and put the job back when the job needs retry. To solve #42456, I should put every time consuming work in worker to make use of concurrency, and remove the barrier in the single-thread producer goroutine. Do you have any suggestions? @gozssky @D3Hunter
…on-job Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
/run-integration-br-test |
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
/run-integration-br-test |
/retest |
/run-integration-br-test |
/run-integration-br-test |
/hold need to fix #42780 (comment) |
Signed-off-by: lance6716 <[email protected]>
/unhold |
/run-integration-br-test |
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
/run-integration-br-test |
@D3Hunter @gozssky PTAL |
Signed-off-by: lance6716 <[email protected]>
/run-integration-br-test |
/retest |
Signed-off-by: lance6716 <[email protected]>
/run-integration-br-test |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 3f90366
|
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
What problem does this PR solve?
Issue Number: close #42456
Problem Summary:
What is changed and how it works?
unfinishedRange
is removed because we don't have a barrier to stop all processing before useunfinishedRange
to generate job. Now the after the job is initially generated, the key range of job will be totally finished by worker, or shrank by partitially ingestion. The job may also be splitted into multiple job whose total key range equals to the original job.Reviews please help check if there's deadlock and if there's a better way to implement it.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.