diff --git a/src/transaction/transaction.rs b/src/transaction/transaction.rs index bf0c6a7b..a9e0f9a7 100644 --- a/src/transaction/transaction.rs +++ b/src/transaction/transaction.rs @@ -15,7 +15,10 @@ use fail::fail_point; use futures::{prelude::*, stream::BoxStream}; use slog::Logger; use std::{iter, ops::RangeBounds, sync::Arc, time::Instant}; -use tikv_client_proto::{kvrpcpb, pdpb::Timestamp}; +use tikv_client_proto::{ + kvrpcpb::{self, Op}, + pdpb::Timestamp, +}; use tokio::{sync::RwLock, time::Duration}; /// An undo-able set of actions on the dataset. @@ -1055,6 +1058,11 @@ struct Committer { } impl Committer { + // CheckNotExists is checked in the prewrite phase and should not appear in the commit phase. + fn filter_out_check_not_exists_mutations(&mut self) { + self.mutations.retain(|m| m.op() != Op::CheckNotExists) + } + async fn commit(mut self) -> Result> { debug!(self.logger, "committing"); @@ -1067,6 +1075,8 @@ impl Committer { return Ok(min_commit_ts); } + self.filter_out_check_not_exists_mutations(); + let commit_ts = if self.options.async_commit { // FIXME: min_commit_ts == 0 => fallback to normal 2PC min_commit_ts.unwrap()