Skip to content

Commit

Permalink
CheckNotExists is checked in the prewrite phase and should not appear…
Browse files Browse the repository at this point in the history
… in the commit phase.
  • Loading branch information
gfreezy committed Aug 24, 2021
1 parent eb1d2da commit 1d31029
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/transaction/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1055,6 +1058,11 @@ struct Committer<PdC: PdClient = PdRpcClient> {
}

impl<PdC: PdClient> Committer<PdC> {
// 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<Option<Timestamp>> {
debug!(self.logger, "committing");

Expand All @@ -1067,6 +1075,8 @@ impl<PdC: PdClient> Committer<PdC> {
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()
Expand Down

0 comments on commit 1d31029

Please sign in to comment.