File tree 1 file changed +7
-2
lines changed
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> {
85
85
. get ( & candidate_region_ver_id)
86
86
. unwrap ( ) ;
87
87
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 ( ) {
89
90
return Ok ( region. clone ( ) ) ;
90
91
}
91
92
}
@@ -102,7 +103,11 @@ impl<C: RetryClientTrait> RegionCache<C> {
102
103
let ver_id = region_cache_guard. id_to_ver_id . get ( & id) ;
103
104
if let Some ( ver_id) = ver_id {
104
105
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
+ }
106
111
}
107
112
108
113
// check concurrent requests
You can’t perform that action at this time.
0 commit comments