Skip to content

Commit 1d31029

Browse files
committed
CheckNotExists is checked in the prewrite phase and should not appear in the commit phase.
1 parent eb1d2da commit 1d31029

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/transaction/transaction.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ use fail::fail_point;
1515
use futures::{prelude::*, stream::BoxStream};
1616
use slog::Logger;
1717
use std::{iter, ops::RangeBounds, sync::Arc, time::Instant};
18-
use tikv_client_proto::{kvrpcpb, pdpb::Timestamp};
18+
use tikv_client_proto::{
19+
kvrpcpb::{self, Op},
20+
pdpb::Timestamp,
21+
};
1922
use tokio::{sync::RwLock, time::Duration};
2023

2124
/// An undo-able set of actions on the dataset.
@@ -1055,6 +1058,11 @@ struct Committer<PdC: PdClient = PdRpcClient> {
10551058
}
10561059

10571060
impl<PdC: PdClient> Committer<PdC> {
1061+
// CheckNotExists is checked in the prewrite phase and should not appear in the commit phase.
1062+
fn filter_out_check_not_exists_mutations(&mut self) {
1063+
self.mutations.retain(|m| m.op() != Op::CheckNotExists)
1064+
}
1065+
10581066
async fn commit(mut self) -> Result<Option<Timestamp>> {
10591067
debug!(self.logger, "committing");
10601068

@@ -1067,6 +1075,8 @@ impl<PdC: PdClient> Committer<PdC> {
10671075
return Ok(min_commit_ts);
10681076
}
10691077

1078+
self.filter_out_check_not_exists_mutations();
1079+
10701080
let commit_ts = if self.options.async_commit {
10711081
// FIXME: min_commit_ts == 0 => fallback to normal 2PC
10721082
min_commit_ts.unwrap()

0 commit comments

Comments
 (0)