diff --git a/pkg/restore/import.go b/pkg/restore/import.go index 3d66f5ae152af..17c05c3cc6b60 100644 --- a/pkg/restore/import.go +++ b/pkg/restore/import.go @@ -24,6 +24,7 @@ var ( ) const ( + importScanResgionTime = 10 * time.Second importFileRetryTimes = 16 importFileWaitInterval = 10 * time.Millisecond importFileMaxWaitInterval = 1 * time.Second @@ -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,