File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ use crate::Key;
31
31
use crate :: KvPair ;
32
32
use crate :: Result ;
33
33
use crate :: Value ;
34
+ use crate :: request:: plan:: is_grpc_error;
34
35
35
36
const MAX_RAW_KV_SCAN_LIMIT : u32 = 10240 ;
36
37
@@ -835,6 +836,17 @@ impl<PdC: PdClient> Client<PdC> {
835
836
}
836
837
Ok ( ( Some ( r) , region. end_key ( ) ) )
837
838
}
839
+ Err ( err) if is_grpc_error ( & err) => {
840
+ debug ! ( "retryable_scan: grpc error: {:?}" , err) ;
841
+ plan:: handle_rpc_error ( self . rpc . clone ( ) , store. clone ( ) ) . await ;
842
+
843
+ if let Some ( duration) = scan_args. backoff . next_delay_duration ( ) {
844
+ sleep ( duration) . await ;
845
+ continue ;
846
+ } else {
847
+ return Err ( err) ;
848
+ }
849
+ }
838
850
Err ( err) => Err ( err) ,
839
851
} ;
840
852
}
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ impl<Req: KvRequest + StoreRequest> StoreRequest for Dispatch<Req> {
87
87
const MULTI_REGION_CONCURRENCY : usize = 16 ;
88
88
const MULTI_STORES_CONCURRENCY : usize = 16 ;
89
89
90
- fn is_grpc_error ( e : & Error ) -> bool {
90
+ pub ( crate ) fn is_grpc_error ( e : & Error ) -> bool {
91
91
matches ! ( e, Error :: GrpcAPI ( _) | Error :: Grpc ( _) )
92
92
}
93
93
@@ -345,6 +345,18 @@ pub(crate) async fn handle_region_error<PdC: PdClient>(
345
345
}
346
346
}
347
347
348
+ pub ( crate ) async fn handle_rpc_error < PdC : PdClient > (
349
+ pd_client : Arc < PdC > ,
350
+ region_store : RegionStore ,
351
+ ) {
352
+ let ver_id = region_store. region_with_leader . ver_id ( ) ;
353
+ let store_id = region_store. region_with_leader . get_store_id ( ) ;
354
+ pd_client. invalidate_region_cache ( ver_id) . await ;
355
+ if let Ok ( store_id) = store_id {
356
+ pd_client. invalidate_store_cache ( store_id) . await ;
357
+ }
358
+ }
359
+
348
360
// Returns
349
361
// 1. Ok(true): error has been resolved, retry immediately
350
362
// 2. Ok(false): backoff, and then retry
You can’t perform that action at this time.
0 commit comments