Skip to content

Commit 906b29c

Browse files
committed
fix CleanupLocksResult merge
Signed-off-by: haojinming <jinming.hao@pingcap.com>
1 parent ebed8bf commit 906b29c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/request/plan.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,12 @@ pub struct CleanupLocksResult {
450450
// TODO: pub resolved_locks: usize,
451451
}
452452

453+
impl CleanupLocksResult {
454+
fn has_error(&self) -> bool {
455+
self.key_error.is_some() || self.region_error.is_some()
456+
}
457+
}
458+
453459
impl Clone for CleanupLocksResult {
454460
fn clone(&self) -> Self {
455461
Self {
@@ -478,8 +484,14 @@ impl Merge<CleanupLocksResult> for Collect {
478484
input
479485
.into_iter()
480486
.fold(Ok(CleanupLocksResult::default()), |acc, x| {
487+
let new_ret = x?;
488+
let new_lock_cnt = if new_ret.has_error() {
489+
0
490+
} else {
491+
new_ret.meet_locks
492+
};
481493
Ok(CleanupLocksResult {
482-
meet_locks: acc?.meet_locks + x?.meet_locks,
494+
meet_locks: acc?.meet_locks + new_lock_cnt,
483495
..Default::default()
484496
})
485497
})

0 commit comments

Comments
 (0)