Skip to main content

ChaosConfiguration

Struct ChaosConfiguration 

Source
pub struct ChaosConfiguration {
Show 22 fields pub clog_probability: f64, pub clog_duration: Range<Duration>, pub partition_probability: f64, pub partition_duration: Range<Duration>, pub bit_flip_probability: f64, pub bit_flip_min_bits: u32, pub bit_flip_max_bits: u32, pub bit_flip_cooldown: Duration, pub partial_write_max_bytes: usize, pub partial_read_max_bytes: usize, pub random_close_probability: f64, pub random_close_cooldown: Duration, pub random_close_explicit_ratio: f64, pub clock_drift_enabled: bool, pub clock_drift_max: Duration, pub buggified_delay_enabled: bool, pub buggified_delay_max: Duration, pub buggified_delay_probability: f64, pub connect_failure_mode: ConnectFailureMode, pub connect_failure_probability: f64, pub max_pair_latency: Range<Duration>, pub partition_strategy: PartitionStrategy,
}
Expand description

Configuration for chaos injection in simulations.

This struct contains all settings related to fault injection and chaos testing, following FoundationDB’s BUGGIFY patterns for deterministic testing.

Fields§

§clog_probability: f64

Clogging probability for individual writes (0.0 - 1.0)

§clog_duration: Range<Duration>

Duration range for clog delays

§partition_probability: f64

Network partition probability (0.0 - 1.0)

§partition_duration: Range<Duration>

Duration range for network partitions

§bit_flip_probability: f64

Bit flip probability for packet corruption (0.0 - 1.0)

§bit_flip_min_bits: u32

Minimum number of bits to flip (power-law distribution lower bound)

§bit_flip_max_bits: u32

Maximum number of bits to flip (power-law distribution upper bound)

§bit_flip_cooldown: Duration

Cooldown duration after bit flip to prevent excessive corruption

§partial_write_max_bytes: usize

Maximum bytes for partial write simulation (BUGGIFY truncates writes to 0-max_bytes) Following FDB’s approach of truncating writes to test TCP backpressure handling

§partial_read_max_bytes: usize

Maximum bytes for partial read simulation (BUGGIFY truncates reads to 1-max_bytes) Mirrors FDB’s Sim2Conn partial delivery on the receiver to test short reads and message reassembly. Always delivers at least one byte so a partial read is never mistaken for EOF.

§random_close_probability: f64

Random connection close probability per I/O operation (0.0 - 1.0) FDB default: 0.00001 (0.001%) - see sim2.actor.cpp:584

§random_close_cooldown: Duration

Cooldown duration after a random close event (prevents cascading failures) FDB uses connectionFailuresDisableDuration - see sim2.actor.cpp:583

§random_close_explicit_ratio: f64

Ratio of explicit exceptions vs silent failures (0.0 - 1.0) FDB default: 0.3 (30% explicit) - see sim2.actor.cpp:602

§clock_drift_enabled: bool

Enable clock drift simulation When enabled, timer() can return a time up to clock_drift_max ahead of now() FDB ref: sim2.actor.cpp:1058-1064

§clock_drift_max: Duration

Maximum clock drift (default 100ms per FDB) timer() can be up to this much ahead of now()

§buggified_delay_enabled: bool

Enable buggified delays on sleep/timer operations When enabled, 25% of sleep operations get extra delay FDB ref: sim2.actor.cpp:1100-1105

§buggified_delay_max: Duration

Maximum additional delay for buggified sleep (default 100ms) Uses power-law distribution: max_delay * pow(random01(), 1000.0) FDB ref: sim2.actor.cpp:1104

§buggified_delay_probability: f64

Probability of adding buggified delay (default 25% per FDB)

§connect_failure_mode: ConnectFailureMode

Connection establishment failure mode (per FDB) FDB ref: sim2.actor.cpp:1243-1250 (SIM_CONNECT_ERROR_MODE)

§connect_failure_probability: f64

Probability of connect failure when Probabilistic mode is enabled (default 50%)

§max_pair_latency: Range<Duration>

Permanent per-IP-pair latency range (FDB SimClogging::MAX_CLOGGING_LATENCY). Each ordered IP pair samples a fixed latency from this range at first contact (via sample_duration), then adds it to every delivery on that pair for the whole run — modelling a stably-slow link. An all-zero range (end is zero) disables it, leaving behavior unchanged. FDB’s MAX * random01() is the ZERO..MAX case. FDB ref: sim2.actor.cpp ~294-299, 352-354.

§partition_strategy: PartitionStrategy

Network partition strategy. Controls how nodes are selected for partitioning. TigerBeetle ref: packet_simulator.zig partition modes

§Real-World Scenario

Different strategies test different failure scenarios:

  • Random: unpredictable chaos
  • UniformSize: various quorum sizes
  • IsolateSingle: single node isolation (common in production)

Implementations§

Source§

impl ChaosConfiguration

Source

pub fn disabled() -> Self

Create a configuration with all chaos disabled (for fast local testing)

Source

pub fn random_for_seed() -> Self

Create a randomized chaos configuration for seed-based testing

Source

pub fn swarm_for_seed() -> Self

Create a swarm-testing chaos configuration for seed-based testing.

Starts from random_for_seed, then disables each fault family with ~50% probability (drawn from the independent CONFIG_RNG stream). This implements swarm testing (Groce et al., ISSTA 2012): each seed exercises a random subset of fault families — including the all-off subset — instead of every family being slightly on at once (which lets families crowd each other out, the passive-suppression anti-pattern).

Source

pub fn apply_buggify_knobs(&mut self)

Spike selected fault magnitudes under buggify (FDB’s if (randomize && BUGGIFY) KNOB = random(lo, hi)).

Composes on top of random_for_seed / swarm_for_seed: each knob keeps its sampled value unless its own buggify_knob! call site fires for the seed, in which case it jumps to an aggressive value within bounds. A representative subset — extend by adding more buggify_knob! lines.

Trait Implementations§

Source§

impl Clone for ChaosConfiguration

Source§

fn clone(&self) -> ChaosConfiguration

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChaosConfiguration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChaosConfiguration

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more