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

test: fix the stuck issue when use raw kv restore #51885

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
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
40 changes: 22 additions & 18 deletions br/pkg/restore/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func NewFileImporter(
}

func (importer *FileImporter) ShouldBlock() bool {
if importer != nil {
if importer != nil && importer.useTokenBucket {
return importer.downloadTokensMap.ShouldBlock() || importer.ingestTokensMap.ShouldBlock()
}
return false
Expand Down Expand Up @@ -1113,15 +1113,17 @@ func (importer *FileImporter) downloadSSTV2(
for _, p := range regionInfo.Region.GetPeers() {
peer := p
eg.Go(func() error {
tokenCh := importer.downloadTokensMap.acquireTokenCh(peer.GetStoreId(), importer.concurrencyPerStore)
select {
case <-ectx.Done():
return ectx.Err()
case <-tokenCh:
if importer.useTokenBucket {
tokenCh := importer.downloadTokensMap.acquireTokenCh(peer.GetStoreId(), importer.concurrencyPerStore)
select {
case <-ectx.Done():
return ectx.Err()
case <-tokenCh:
}
defer func() {
importer.releaseToken(tokenCh)
}()
}
defer func() {
importer.releaseToken(tokenCh)
}()
for _, file := range files {
req, ok := downloadReqsMap[file.Name]
if !ok {
Expand Down Expand Up @@ -1259,15 +1261,17 @@ func (importer *FileImporter) ingest(
info *split.RegionInfo,
downloadMetas []*import_sstpb.SSTMeta,
) error {
tokenCh := importer.ingestTokensMap.acquireTokenCh(info.Leader.GetStoreId(), importer.concurrencyPerStore)
select {
case <-ctx.Done():
return ctx.Err()
case <-tokenCh:
}
defer func() {
importer.releaseToken(tokenCh)
}()
if importer.useTokenBucket {
tokenCh := importer.ingestTokensMap.acquireTokenCh(info.Leader.GetStoreId(), importer.concurrencyPerStore)
select {
case <-ctx.Done():
return ctx.Err()
case <-tokenCh:
}
defer func() {
importer.releaseToken(tokenCh)
}()
}
for {
ingestResp, errIngest := importer.ingestSSTs(ctx, downloadMetas, info)
if errIngest != nil {
Expand Down
Loading