dag: add fail points on opening namedag

Summary:
It turns out that the namedag was opened multiple times. Add a fail point to
help figure out the callsite.

The `fail` crate allows something like:

  FAILPOINTS="dag-namedag-open=1*sleep(1)->return"
  FAILPOINTS="dag-namedag-open=1*sleep(1)->panic"

Meaning that the first open causes 1ms sleep, and the second
causes an error (turns into a Python backtrace), or a panic (turns into a Rust
backtrace with RUST_BACKTRACE=1).

Reviewed By: andll

Differential Revision: D29888937

fbshipit-source-id: b1644d7196f68262523ab9a5fc4fb110a4cc0062
This commit is contained in:
Jun Wu 2021-07-26 15:21:54 -07:00 committed by Facebook GitHub Bot
parent 1dc90d221e
commit 8cb3d3dd75
3 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,7 @@ bitflags = "1.2"
byteorder = "1.3"
dag-types = { path = "dag-types" }
drawdag = { path = "../drawdag" }
fail = { version = "0.4", features = ["failpoints"] }
fs2 = { version = "0.4", optional = true }
futures = { version = "0.3.13", features = ["async-await", "compat"] }
indexedlog = { path = "../indexedlog", optional = true }

View File

@ -74,5 +74,17 @@ pub type Result<T> = std::result::Result<T, Error>;
pub use indexedlog::Repair;
pub use nonblocking;
#[macro_export]
macro_rules! failpoint {
($name:literal) => {
::fail::fail_point!($name, |_| {
let msg = format!("failpoint injected by FAILPOINTS: {}", $name);
Err($crate::errors::DagError::from(
$crate::errors::BackendError::Generic(msg),
))
})
};
}
#[cfg(test)]
dev_logger::init!();

View File

@ -42,6 +42,7 @@ impl Open for IndexedLogNameDagPath {
type OpenTarget = NameDag;
fn open(&self) -> Result<Self::OpenTarget> {
crate::failpoint!("dag-namedag-open");
let path = &self.0;
let opts = NameDag::default_open_options();
let mut mlog = opts.open(path)?;