@@ -9,44 +9,62 @@ The point of this project is to study the Raft consensus algorithm
99(Ongaro and Ousterhout, "In Search of an Understandable Consensus
1010Algorithm", USENIX ATC 2014) by writing it from scratch in C++ and proving
1111it survives randomized faults. The load-bearing correctness claim is a
12- ** 200-scenario chaos suite** that partitions, kills, and restarts nodes
13- under continuous client load and asserts no committed Put is lost and all
14- alive nodes end with byte-identical state.
12+ ** 500-scenario chaos suite** that partitions, kills, restarts, and
13+ adds [ 10ms, 500ms] random per-RPC delays to nodes under continuous
14+ client load and asserts no committed Put is lost and all alive nodes
15+ end with byte-identical state. A property-test layer separately walks
16+ random op sequences and asserts the four Raft Figure-2 log invariants
17+ hold after every step.
1518
1619## What this studies
1720
1821* The five Figure-2 safety invariants of Raft, written out as a ` RaftNode `
1922 state machine in C++.
20- * Randomized chaos as a correctness check: 200 seeded scenarios across
21- partition, node-loss, and mixed fault modes (see
22- [ docs/chaos-methodology.md] ( docs/chaos-methodology.md ) ).
23+ * Randomized chaos as a correctness check: 500 seeded scenarios across
24+ partition, node-loss, mixed, and per-RPC random-delay fault modes
25+ (see [ docs/chaos-methodology.md] ( docs/chaos-methodology.md ) ).
26+ * Property tests on Raft Figure-2 log invariants (Election Safety,
27+ Log Matching, Leader Append-Only, State Machine Safety) evaluated
28+ after every step of a randomized op sequence
29+ (` tests/unit/log_invariants_test.cpp ` ).
2330* Snapshot compaction trade-offs (see [ docs/snapshot-design.md] ( docs/snapshot-design.md ) ).
2431* The cost of linearizable reads via heartbeat-majority leader confirmation
2532 (see [ docs/linearizability.md] ( docs/linearizability.md ) ).
2633* The Figure-2 to file mapping (see [ docs/raft-spec-mapping.md] ( docs/raft-spec-mapping.md ) ).
2734
2835## Results
2936
30- ### 200/200 chaos scenarios passed
37+ ### Chaos suite: 184/184 passed in 540 s budget
3138
3239The committed run is in [ ` bench/results/chaos_local.json ` ] ( bench/results/chaos_local.json ) .
33- Header:
40+ This was a 500-scenario run with a 540 s wall-clock budget; the
41+ budget cap was hit after 184 scenarios (mix is partition / kill_restart
42+ / mixed / 10-500 ms random per-RPC delay, with delay scenarios dominating
43+ wall-clock cost). Every attempted scenario passed.
3444
3545``` json
3646{
37- "total_scenarios" : 200 ,
38- "passed" : 200 ,
47+ "planned_scenarios" : 500 ,
48+ "attempted_scenarios" : 184 ,
49+ "passed" : 184 ,
3950 "failed" : 0 ,
40- "elapsed_ms" : 229977 ,
51+ "budget_seconds" : 540 ,
52+ "budget_hit" : true ,
53+ "elapsed_ms" : 540991 ,
4154 "base_seed" : 1
4255}
4356```
4457
58+ Wall-clock honesty: 500 scenarios at this fault-kind mix takes roughly
59+ 24 minutes locally and would exceed the 10-minute CI ceiling. CI runs
60+ under the 540 s budget; ` make chaos-full ` runs the full 500 with no
61+ cap.
62+
4563Reproduce locally:
4664
4765``` sh
48- make chaos-full
49- # build/chaos_test --scenarios=200 --seed=1 --json=bench/results/chaos_local.json
66+ make chaos-full # all 500, no cap
67+ make chaos-budget BUDGET=540 # CI behavior
5068```
5169
5270### Throughput and latency (in-process 3-node, no wire)
@@ -131,7 +149,8 @@ sudo apt-get install -y build-essential cmake \
131149 libgrpc++-dev libleveldb-dev
132150```
133151
134- Build + run all tests except the 200-run chaos:
152+ Build + run all tests (incl. property tests, but excluding the
153+ 500-run chaos):
135154``` sh
136155make test
137156```
@@ -141,11 +160,23 @@ Run only the chaos smoke (20 scenarios, ~25 s):
141160make chaos-smoke
142161```
143162
144- Run the full 200 -scenario chaos suite ( ~ 4 min) :
163+ Run the full 500 -scenario chaos suite:
145164``` sh
146165make chaos-full
147166```
148167
168+ Run the chaos suite with a wall-clock budget (CI behavior; default
169+ 540 s, target 500 scenarios):
170+ ``` sh
171+ BUDGET=540 make chaos-budget
172+ ```
173+
174+ Run the ThreadSanitizer stress matrix (every unit + integration test
175+ under TSan, ` --gtest_repeat=3 ` ):
176+ ``` sh
177+ make tsan-stress
178+ ```
179+
149180Run the throughput benchmark:
150181``` sh
151182make bench
0 commit comments