-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
restore: use token bucket to balance download requests. #49887
Conversation
Skipping CI for Draft Pull Request. |
Hi @3pointer. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Wait for https://github.com/pingcap/tidb/pull/48244/files merge first |
2c60f61
to
d7d32b7
Compare
/ok-to-tests |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #49887 +/- ##
=================================================
- Coverage 79.3229% 67.3070% -12.0160%
=================================================
Files 2447 2558 +111
Lines 673700 840148 +166448
=================================================
+ Hits 534399 565479 +31080
- Misses 117932 250900 +132968
- Partials 21369 23769 +2400
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/test pull-br-integration-test |
@3pointer: The specified target(s) for
The following commands are available to trigger optional jobs:
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@3pointer: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test pull-br-integration-test |
@3pointer: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
rest lgtm
br/pkg/restore/import.go
Outdated
for _, sstMeta := range resultMetasMap { | ||
downloadMetas = append(downloadMetas, sstMeta) | ||
} | ||
return downloadMetas, nil |
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.
for _, sstMeta := range resultMetasMap { | |
downloadMetas = append(downloadMetas, sstMeta) | |
} | |
return downloadMetas, nil | |
return maps.Values(resultMetasMap), nil |
} | ||
|
||
mu.Lock() | ||
sstMeta, ok := downloadMetasMap[file.Name] |
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 will perfer make a small closure and use defer
for unlocking.
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 feel like is a tiny logic flaw, no need to make closure.
br/pkg/restore/import.go
Outdated
sstMeta, ok := downloadMetasMap[file.Name] | ||
if !ok { | ||
mu.Unlock() | ||
return errors.New("not found file key for download sstMeta") |
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.
Please also provide the file name (perhaps also the content of the map) here. (Is this code really reachable? Maybe panic here is also acceptable.)
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.
is unreachable. just a protect code.
br/pkg/restore/import.go
Outdated
} | ||
var err error | ||
var resp *import_sstpb.DownloadResponse | ||
err = utils.WithRetry(ctx, func() error { |
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.
Maybe try utils.WithRetryV2
, which allows us get the return value directly.
return errors.Annotate(berrors.ErrKVDownloadFailed, resp.GetError().GetMessage()) | ||
} | ||
if resp.GetIsEmpty() { | ||
return errors.Trace(berrors.ErrKVRangeIsEmpty) |
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.
Maybe also provide the range of the file for debugging.
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 had log outside
log.Warn("download file skipped",
logutil.Files(files),
logutil.Region(info.Region),
logutil.Key("startKey", startKey),
logutil.Key("endKey", endKey),
logutil.Key("file-simple-start", files[0].StartKey),
logutil.Key("file-simple-end", files[0].EndKey),
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.
It seems the file's key range won't be surely printed? We only print the first file there. Even in most case there should be only one file, querying log is usually harder than the direct error message.
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.
ErrKVRangeIsEmpty
is always a retryable error
and never break the restoration. it appears somehow doesn't really means error. I think is kind of feature rather than error.
Co-authored-by: 山岚 <[email protected]>
…into patch_per_store_concurrency
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.
rest lgtm
return errors.Annotate(berrors.ErrKVDownloadFailed, resp.GetError().GetMessage()) | ||
} | ||
if resp.GetIsEmpty() { | ||
return errors.Trace(berrors.ErrKVRangeIsEmpty) |
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.
It seems the file's key range won't be surely printed? We only print the first file there. Even in most case there should be only one file, querying log is usually harder than the direct error message.
br/pkg/restore/import.go
Outdated
sstMeta, ok := downloadMetasMap[file.Name] | ||
if !ok { | ||
mu.Unlock() | ||
return errors.Errorf("not found file key for download sstMeta", file.Name) |
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.
It seems there isn't a printf
placeholder in the format string.
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.
fixed
/retest |
1 similar comment
/retest |
br/pkg/restore/client.go
Outdated
stores, err := conn.GetAllTiKVStoresWithRetry(ctx, rc.pdClient, util.SkipTiFlash) | ||
if err != nil { | ||
log.Fatal("failed to get stores", zap.Error(err)) | ||
} | ||
concurrencyPerStore := 512 | ||
concurrencyPerStore := rc.GetConcurrencyPerStore() | ||
for _, store := range stores { | ||
ch := make(chan struct{}, concurrencyPerStore) | ||
for i := 0; i < concurrencyPerStore; i += 1 { | ||
ch <- struct{}{} | ||
} | ||
ch := utils.BuildWorkerTokenChannel(concurrencyPerStore) |
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.
actually only when useToKenBucket == true, the storeWorkerPoolMap need to be initialized.
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.
yes, but I think it's okay to keep it here.
br/pkg/restore/client.go
Outdated
rc.workerPool = utils.NewWorkerPool(c, "file") | ||
rc.concurrencyPerStore = c |
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.
does it need to be removed?
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.
yes
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Leavrth, YuJuncen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@3pointer: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: ref #49886
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.