1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Failpoint support for deterministic crash testing.
//!
//! Failpoints allow injecting failures at specific points in the code
//! to test recovery and error handling paths.
//!
//! # Usage
//!
//! In production code, add failpoints at critical locations:
//!
//! ```ignore
//! use crate::fail_point;
//!
//! // In flush.rs after SSTable write
//! fail_point!("flush::after_sstable_write");
//!
//! // In wal.rs after WAL sync
//! fail_point!("wal::after_sync");
//! ```
//!
//! In tests, inject failures:
//!
//! ```ignore
//! fail::cfg("flush::after_sstable_write", "panic").unwrap();
//! // ... test recovery ...
//! fail::remove("flush::after_sstable_write");
//! ```
//!
//! # Available Failpoints
//!
//! | Failpoint | Location | Tests |
//! |-----------|----------|-------|
//! | `flush::after_sstable_write` | After SSTable fsync, before WAL clear | WAL data preserved on crash |
//! | `flush::before_wal_clear` | Just before WAL is cleared | Recovery replays WAL |
//! | `compaction::after_output_write` | After new SSTable, before input deletion | Inputs preserved |
//! | `wal::after_sync` | After WAL sync completes | Data durability |
//!
//! # Feature Flag
//!
//! Failpoints are only compiled when the `failpoints` feature is enabled.
//! In release builds without this feature, all failpoint macros compile to nothing.
/// Failpoint macro - compiles to nothing without the feature
/// Failpoint macro - delegates to fail crate when enabled