Skip to content

Commit

Permalink
add timeout for import context (pingcap#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer authored Nov 6, 2019
1 parent 11db863 commit 80a2aa9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/restore/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
)

const (
importScanResgionTime = 10 * time.Second
importFileRetryTimes = 16
importFileWaitInterval = 10 * time.Millisecond
importFileMaxWaitInterval = 1 * time.Second
Expand Down Expand Up @@ -69,8 +70,10 @@ func (importer *FileImporter) Import(file *backup.File, rewriteRules *restore_ut
// bigger than all of the data keys as endKey here.
endKey = append(tablecodec.GenTablePrefix(startTableID), 0xff)
}
ctx, cancel := context.WithTimeout(importer.ctx, importScanResgionTime)
defer cancel()
regionInfos, err := importer.client.ScanRegions(
importer.ctx,
ctx,
rewriteRawKeyWithNewPrefix(startKey, rewriteRules),
rewriteRawKeyWithNewPrefix(endKey, rewriteRules),
0,
Expand Down

0 comments on commit 80a2aa9

Please sign in to comment.