Skip to content

Commit

Permalink
change to fail point
Browse files Browse the repository at this point in the history
Signed-off-by: pingyu <yuping@pingcap.com>
  • Loading branch information
pingyu committed Oct 10, 2022
1 parent 5779041 commit f172881
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 35 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ failpoints = [
"raftstore/failpoints",
"tikv_util/failpoints",
"engine_rocks/failpoints",
"causal_ts/failpoints",
]
cloud-aws = [
"encryption_export/cloud-aws",
Expand Down
1 change: 0 additions & 1 deletion components/causal_ts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ publish = false

[features]
testexport = []
failpoints = ["fail/failpoints"]

[dependencies]
api_version = { path = "../api_version", default-features = false }
Expand Down
22 changes: 0 additions & 22 deletions components/causal_ts/src/tso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use std::{
};

use async_trait::async_trait;
use futures::compat::Future01CompatExt;
#[cfg(test)]
use futures::executor::block_on;
use parking_lot::RwLock;
Expand Down Expand Up @@ -623,27 +622,6 @@ impl<C: PdClient + 'static> CausalTsProvider for BatchTsoProvider<C> {
}

async fn async_flush(&self) -> Result<TimeStamp> {
// #[cfg(feature = "failpoints")]
{
let should_fail = (|| {
fail::fail_point!("causal_ts_provider_flush", |_| true);
false
})();
if should_fail {
// Sleep to avoid busy loop in `handle_update_max_timestamp()`.
let _ = tikv_util::timer::GLOBAL_TIMER_HANDLE
.delay(std::time::Instant::now() + Duration::from_millis(100))
.compat()
.await;
return Err(box_err!("async_flush err(failpoints)"));
}
}

// fail::fail_point!("causal_ts_provider_flush", |_| {
// // Sleep to avoid busy loop in `handle_update_max_timestamp()`.
// std::thread::sleep(Duration::from_millis(200));
// Err(box_err!("async_flush err(failpoints)"))
// });
self.renew_tso_batch(true, TsoBatchRenewReason::flush)
.await?;
// TODO: Return the first tso by renew_tso_batch instead of async_get_ts
Expand Down
22 changes: 11 additions & 11 deletions tests/failpoints/cases/test_rawkv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl TestSuite {
}
}

const FP_CAUSAL_TS_PROVIDER_FLUSH: &str = "causal_ts_provider_flush";
const FP_GET_TSO: &str = "test_raftstore_get_tso";

/// Verify correctness on leader transfer.
// TODO: simulate and test for the scenario of issue #12498.
Expand All @@ -164,8 +164,8 @@ fn test_leader_transfer() {
assert_eq!(suite.must_raw_get(key1), Some(b"v4".to_vec()));
}

// Disable CausalObserver::flush_timestamp to produce causality issue.
fail::cfg(FP_CAUSAL_TS_PROVIDER_FLUSH, "return").unwrap();
// Make causal_ts_provider.async_flush() & handle_update_max_timestamp fail.
fail::cfg(FP_GET_TSO, "return(50)").unwrap();

// Transfer leader and write to store 2.
{
Expand All @@ -182,8 +182,8 @@ fn test_leader_transfer() {
// Transfer leader back.
suite.must_transfer_leader(&region, 1);
suite.must_leader_on_store(key1, 1);
// Enable CausalObserver::flush_timestamp.
fail::cfg(FP_CAUSAL_TS_PROVIDER_FLUSH, "off").unwrap();
// Make handle_update_max_timestamp succeed.
fail::cfg(FP_GET_TSO, "off").unwrap();
// Transfer leader and write to store 2 again.
{
suite.must_transfer_leader(&region, 2);
Expand All @@ -195,7 +195,7 @@ fn test_leader_transfer() {
assert_eq!(suite.must_raw_get(key1), Some(b"v8".to_vec()));
}

fail::remove(FP_CAUSAL_TS_PROVIDER_FLUSH);
fail::remove(FP_GET_TSO);
suite.stop();
}

Expand Down Expand Up @@ -238,8 +238,8 @@ fn test_region_merge() {
assert_eq!(suite.must_raw_get(keys[1]), Some(b"v4".to_vec()));
}

// Disable CausalObserver::flush_timestamp to produce causality issue.
fail::cfg(FP_CAUSAL_TS_PROVIDER_FLUSH, "return").unwrap();
// Make causal_ts_provider.async_flush() & handle_update_max_timestamp fail.
fail::cfg(FP_GET_TSO, "return(50)").unwrap();

// Merge region 1 to 3.
{
Expand All @@ -253,8 +253,8 @@ fn test_region_merge() {
assert_eq!(suite.must_raw_get(keys[1]), Some(b"v4".to_vec()));
}

// Enable CausalObserver::flush_timestamp.
fail::cfg(FP_CAUSAL_TS_PROVIDER_FLUSH, "off").unwrap();
// Make handle_update_max_timestamp succeed.
fail::cfg(FP_GET_TSO, "off").unwrap();

// Merge region 3 to 5.
{
Expand All @@ -268,6 +268,6 @@ fn test_region_merge() {
assert_eq!(suite.must_raw_get(keys[1]), Some(b"v8".to_vec()));
}

fail::remove(FP_CAUSAL_TS_PROVIDER_FLUSH);
fail::remove(FP_GET_TSO);
suite.stop();
}

0 comments on commit f172881

Please sign in to comment.