File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ impl<C: RetryClientTrait> RegionCache<C> {
8585 . get ( & candidate_region_ver_id)
8686 . unwrap ( ) ;
8787
88- if region. contains ( key) {
88+ // Region in cache maybe stale if the region has not been elected leader yet during start.
89+ if region. contains ( key) && region. leader . is_some ( ) {
8990 return Ok ( region. clone ( ) ) ;
9091 }
9192 }
@@ -102,7 +103,11 @@ impl<C: RetryClientTrait> RegionCache<C> {
102103 let ver_id = region_cache_guard. id_to_ver_id . get ( & id) ;
103104 if let Some ( ver_id) = ver_id {
104105 let region = region_cache_guard. ver_id_to_region . get ( ver_id) . unwrap ( ) ;
105- return Ok ( region. clone ( ) ) ;
106+
107+ // Region in cache maybe stale if the region has not been elected leader yet during start.
108+ if region. leader . is_some ( ) {
109+ return Ok ( region. clone ( ) ) ;
110+ }
106111 }
107112
108113 // check concurrent requests
You can’t perform that action at this time.
0 commit comments