Repository navigation
Fence local writes against step-down with a role lock - #8921
Amaury Chamayou (achamayou) merged 11 commits into
Conversation
A local writer (RPC transaction, emit_signature, snapshot evidence) could publish to the KV and Merkle history after its node had stepped down, racing follower execute_append_entries_sync. This made the follower reject valid entries or retain a stale leaf. Store now has a role_rwlock and a can_write_locally flag. Local writes take a shared permit before mutating maps, version or history, and release it before replicate. Aft closes the gate under unique_lock on every demotion (including RetiredCommitted, after compact returns), rolls back to last_idx only on a writable->non-writable transition, and reopens it only on become_leader. replicate no longer rolls back. next_txid returns nullopt when local writes are disabled. Store::commit now also checks rollback_count before appending to history, not just to the chunker. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
A pending snapshot's COSE signatures and serialised tree are now tagged with their source signature index, cleared when rollback truncates past it, and only persisted once that signature is committed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
commit_reserved refuses once local writes are disabled, a snapshot request without handles is no longer silently dropped, and a turnstile stops local writers starving a demotion waiting for the role lock. The in-flight demotion test now holds the consensus lock before releasing the writer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
A snapshot request with no handles is never made in practice, and changing how it behaves is unrelated to fencing local writes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
Local writers now check one atomic, rather than locking a global mutex, on every write. A writer which sees a pending role change is refused without taking role_rwlock, so consensus still only waits for writers already in flight. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
Aft now owns the role lock and whether local writes are accepted, and derives the latter from its leadership state through a single helper, instead of enabling and disabling the Store's writes ad hoc. The Store forwards permit requests to its consensus, and accepts local writes without one. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
A moved-from permit no longer allows writes, and a permit keeps the consensus whose lock it holds alive until it releases it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
There was a problem hiding this comment.
🟡 Changes recommended
Missing deterministic same-term step-down coverage during KV application leaves demotion fencing and cleanup of speculative writes and hook metadata unverified.
1 open issue
What changed in this PR
This PR fences CCF local writes during leadership changes to prevent KV and Merkle history divergence.
Changes:
- Add role-lock permits and move speculative rollback to demotion.
- Reject stale publication and discard rolled-back snapshot receipt material.
- Extend regression tests and adapt callers to optional transaction IDs.
Custom instructions used
.github/instructions/reviewing.instructions.md- Testing skill guidance.
| File | Description |
|---|---|
| src/node/test/snapshotter.cpp | Test receipt and evidence rollback. |
| src/node/test/history.cpp | Adapt transaction ID reservations. |
| src/node/test/historical_queries.cpp | Adapt signature transaction reservation. |
| src/node/snapshotter.h | Invalidate rolled-back receipt material and evidence. |
| src/node/history.h | Skip signatures when reservation is refused. |
| src/kv/test/null_tx_history.h | Handle refused signature reservations. |
| src/kv/test/kv_test.cpp | Adapt optional transaction IDs. |
| src/kv/test/kv_serialisation.cpp | Adapt reserved transaction setup. |
| src/kv/store.h | Fence writes and validate history publication. |
| src/kv/kv_types.h | Define write permits and updated interfaces. |
| src/kv/committable_tx.h | Fence local transaction application. |
| src/consensus/aft/test/view_straddling_rollback.cpp | Pause stale transactions before replication. |
| src/consensus/aft/test/view_straddling_history.cpp | Cover demotion, retirement, and re-election. |
| src/consensus/aft/test/view_straddling_common.h | Extend concurrency test helpers. |
| src/consensus/aft/test/main.cpp | Adapt transaction ID reservations. |
| src/consensus/aft/cft.h | Coordinate role changes, write admission, and rollback. |
| .changes/local-writes-fenced-on-step-down.fixed.md | Describe the divergence fix. |
Review effort: Balanced
|
Full benchmark run (Virtual and SNP) for 7a85e5f: https://github.com/microsoft/CCF/actions/runs/47085554792 |
|
Bench A/B style comparison for the full benchmark runs on 7a85e5f (1, 2, 3, 4, 5), generated locally with VirtualDescriptionComparing 5 available runs from this branch (#8921) against the trend of the last 30 Each chart plots every benchmark as an axis, with values normalized so 100 is the EWMA baseline of recent Axis labels show the latest branch value and its difference from the main EWMA baseline, where 0% is on the baseline. They are coloured green where the latest run improves on the baseline, red where it regresses, and grey where the difference is within one std dev of the baseline (within noise). Higher is better for throughput and rate, lower for latency and memory. A benchmark which does not exist on Throughput (tx/s)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#808A94!important}
.radarAxisLabel:nth-of-type(2){fill:#808A94!important}
.radarAxisLabel:nth-of-type(3){fill:#808A94!important}
.radarAxisLabel:nth-of-type(4){fill:#808A94!important}
.radarAxisLabel:nth-of-type(5){fill:#808A94!important}
.radarAxisLabel:nth-of-type(6){fill:#808A94!important}
.radarAxisLabel:nth-of-type(7){fill:#808A94!important}
.radarAxisLabel:nth-of-type(8){fill:#808A94!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["Basic Blocking 100ms: 3,164 tx/s ▬ 0%"]
axis b1["Basic Blocking 20ms: 15,697 tx/s ▬ 0%"]
axis b2["Basic Blocking 2ms: 24,236 tx/s ▬ +5%"]
axis b3["Basic JS: 17,586 tx/s ▬ -1%"]
axis b4["FluentD: 15,706 tx/s ▬ 0%"]
axis b5["Historical Queries: 778,504 tx/s ▬ +5%"]
axis b6["L…g Certificate Blocking: 30,819 tx/s ▬ 0%"]
axis b7["Logging JWT Blocking: 15,727 tx/s ▬ 0%"]
curve stddev2_high["main EWMA + 2 std dev"]{100.37, 100.42, 112.23, 107.09, 100.44, 114.61, 100.80, 100.46}
curve stddev1_high["main EWMA + 1 std dev"]{100.19, 100.21, 106.12, 103.54, 100.22, 107.31, 100.40, 100.23}
curve stddev1_low["main EWMA - 1 std dev"]{99.81, 99.79, 93.88, 96.46, 99.78, 92.69, 99.60, 99.77}
curve stddev2_low["main EWMA - 2 std dev"]{99.63, 99.58, 87.77, 92.91, 99.56, 85.39, 99.20, 99.54}
curve branch_0["#8921 (4 runs earlier)"]{99.97, 100.13, 101.04, 105.72, 99.99, 108.25, 100.11, 99.98}
curve branch_1["#8921 (3 runs earlier)"]{99.94, 99.85, 100.34, 104.60, 99.96, 105.74, 100.20, 99.96}
curve branch_2["#8921 (2 runs earlier)"]{99.70, 99.87, 97.69, 105.95, 100.03, 111.00, 100.18, 100.05}
curve branch_3["#8921 (1 run earlier)"]{100.02, 99.87, 103.38, 101.28, 99.76, 104.59, 100.04, 99.96}
curve branch_4["#8921"]{100.00, 99.89, 105.24, 98.56, 99.95, 105.09, 99.97, 99.94}
graticule polygon
max 125
min 75
ticks 0
showLegend false
Latency (ms)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#808A94!important}
.radarAxisLabel:nth-of-type(2){fill:#808A94!important}
.radarAxisLabel:nth-of-type(3){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(4){fill:#808A94!important}
.radarAxisLabel:nth-of-type(5){fill:#808A94!important}
.radarAxisLabel:nth-of-type(6){fill:#808A94!important}
.radarAxisLabel:nth-of-type(7){fill:#808A94!important}
.radarAxisLabel:nth-of-type(8){fill:#808A94!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["Basic Blocking 100ms: 99 ms ▬ 0%"]
axis b1["Basic Blocking 20ms: 19 ms ▬ 0%"]
axis b2["Basic Blocking 2ms: 12 ms ▼ 8%"]
axis b3["Basic JS: 17 ms ▬ -2%"]
axis b4["FluentD: 19 ms ▬ 0%"]
axis b5["Historical Queries: 39 ms ▬ -4%"]
axis b6["Logging Certificate Blocking: 18 ms ▬ 0%"]
axis b7["Logging JWT Blocking: 19 ms ▬ 0%"]
curve stddev2_high["main EWMA + 2 std dev"]{100.00, 100.00, 114.14, 107.14, 100.00, 119.26, 100.00, 100.00}
curve stddev1_high["main EWMA + 1 std dev"]{100.00, 100.00, 107.07, 103.57, 100.00, 109.63, 100.00, 100.00}
curve stddev1_low["main EWMA - 1 std dev"]{100.00, 100.00, 92.93, 96.43, 100.00, 90.37, 100.00, 100.00}
curve stddev2_low["main EWMA - 2 std dev"]{100.00, 100.00, 85.86, 92.86, 100.00, 80.74, 100.00, 100.00}
curve branch_0["#8921 (4 runs earlier)"]{100.00, 100.00, 99.79, 98.18, 100.00, 93.54, 100.00, 100.00}
curve branch_1["#8921 (3 runs earlier)"]{100.00, 100.00, 99.79, 98.18, 100.00, 98.46, 100.00, 100.00}
curve branch_2["#8921 (2 runs earlier)"]{100.00, 100.00, 99.79, 92.41, 100.00, 100.92, 100.00, 100.00}
curve branch_3["#8921 (1 run earlier)"]{100.00, 100.00, 99.79, 98.18, 100.00, 96.00, 100.00, 100.00}
curve branch_4["#8921"]{100.00, 100.00, 92.11, 98.18, 100.00, 96.00, 100.00, 100.00}
graticule polygon
max 133
min 67
ticks 0
showLegend false
Memory (bytes)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#808A94!important}
.radarAxisLabel:nth-of-type(2){fill:#808A94!important}
.radarAxisLabel:nth-of-type(3){fill:#808A94!important}
.radarAxisLabel:nth-of-type(4){fill:#808A94!important}
.radarAxisLabel:nth-of-type(5){fill:#808A94!important}
.radarAxisLabel:nth-of-type(6){fill:#808A94!important}
.radarAxisLabel:nth-of-type(7){fill:#808A94!important}
.radarAxisLabel:nth-of-type(8){fill:#808A94!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["Basic Blocking 100ms: 56.7 MiB ▬ 0%"]
axis b1["Basic Blocking 20ms: 57.4 MiB ▬ 0%"]
axis b2["Basic Blocking 2ms: 59.3 MiB ▬ +1%"]
axis b3["Basic JS: 66.1 MiB ▬ +1%"]
axis b4["FluentD: 58.3 MiB ▬ +1%"]
axis b5["Historical Queries: 117 MiB ▬ 0%"]
axis b6["Logging Certificate Blocking: 82.4 MiB ▬ +1%"]
axis b7["Logging JWT Blocking: 57.1 MiB ▬ 0%"]
curve stddev2_high["main EWMA + 2 std dev"]{103.25, 103.38, 103.26, 103.54, 103.65, 100.98, 103.74, 106.10}
curve stddev1_high["main EWMA + 1 std dev"]{101.62, 101.69, 101.63, 101.77, 101.82, 100.49, 101.87, 103.05}
curve stddev1_low["main EWMA - 1 std dev"]{98.38, 98.31, 98.37, 98.23, 98.18, 99.51, 98.13, 96.95}
curve stddev2_low["main EWMA - 2 std dev"]{96.75, 96.62, 96.74, 96.46, 96.35, 99.02, 96.26, 93.90}
curve branch_0["#8921 (4 runs earlier)"]{101.15, 99.43, 100.81, 104.05, 101.00, 100.10, 100.59, 98.78}
curve branch_1["#8921 (3 runs earlier)"]{100.30, 99.23, 100.71, 101.72, 100.54, 98.89, 99.69, 99.91}
curve branch_2["#8921 (2 runs earlier)"]{101.42, 100.23, 98.30, 102.79, 101.24, 99.86, 101.30, 99.75}
curve branch_3["#8921 (1 run earlier)"]{101.45, 100.19, 100.34, 102.35, 99.98, 100.42, 100.87, 100.58}
curve branch_4["#8921"]{100.23, 100.04, 100.98, 101.32, 101.17, 100.46, 100.89, 100.42}
graticule polygon
max 111
min 89
ticks 0
showLegend false
Rate (ops/s)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#808A94!important}
.radarAxisLabel:nth-of-type(2){fill:#808A94!important}
.radarAxisLabel:nth-of-type(3){fill:#808A94!important}
.radarAxisLabel:nth-of-type(4){fill:#808A94!important}
.radarAxisLabel:nth-of-type(5){fill:#808A94!important}
.radarAxisLabel:nth-of-type(6){fill:#808A94!important}
.radarAxisLabel:nth-of-type(7){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(8){fill:#808A94!important}
.radarAxisLabel:nth-of-type(9){fill:#808A94!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["CCF c…n c…t lifecycle: 20,138 ops/s ▬ +1%"]
axis b1["CCF fresh JS invocation: 18,527 ops/s ▬ 0%"]
axis b2["CHAMP get: 64,939,595 ops/s ▬ +1%"]
axis b3["CHAMP put: 7,938,292 ops/s ▬ 0%"]
axis b4["KV deserialisation: 3,541,076 ops/s ▬ +1%"]
axis b5["KV serialisation: 2,902,758 ops/s ▬ +1%"]
axis b6["KV s…t deserialisation: 7,448 ops/s ▲ 5%"]
axis b7["KV snapshot serialisation: 7,849 ops/s ▬ +6%"]
axis b8["Q…S s…d c…t lifecycle: 24,088 ops/s ▬ +1%"]
curve stddev2_high["main EWMA + 2 std dev"]{103.83, 104.40, 104.17, 103.82, 104.57, 105.07, 105.04, 119.28, 104.10}
curve stddev1_high["main EWMA + 1 std dev"]{101.91, 102.20, 102.09, 101.91, 102.29, 102.53, 102.52, 109.64, 102.05}
curve stddev1_low["main EWMA - 1 std dev"]{98.09, 97.80, 97.91, 98.09, 97.71, 97.47, 97.48, 90.36, 97.95}
curve stddev2_low["main EWMA - 2 std dev"]{96.17, 95.60, 95.83, 96.18, 95.43, 94.93, 94.96, 80.72, 95.90}
curve branch_0["#8921 (4 runs earlier)"]{101.10, 100.86, 100.88, 103.96, 102.33, 103.19, 104.52, 107.75, 100.79}
curve branch_1["#8921 (3 runs earlier)"]{101.45, 101.71, 101.46, 100.58, 103.81, 101.69, 106.10, 120.19, 102.39}
curve branch_2["#8921 (2 runs earlier)"]{101.49, 102.05, 101.36, 101.77, 100.56, 103.81, 105.01, 108.22, 101.99}
curve branch_3["#8921 (1 run earlier)"]{96.10, 96.36, 98.13, 100.17, 104.61, 101.69, 103.04, 95.21, 96.77}
curve branch_4["#8921"]{100.82, 100.49, 100.91, 99.60, 101.28, 101.10, 104.52, 106.36, 101.12}
graticule polygon
max 135
min 66
ticks 0
showLegend false
SNP (ACI Genoa)DescriptionComparing 5 available runs from this branch (#8921) against the trend of the last 30 Each chart plots every benchmark as an axis, with values normalized so 100 is the EWMA baseline of recent Axis labels show the latest branch value and its difference from the main EWMA baseline, where 0% is on the baseline. They are coloured green where the latest run improves on the baseline, red where it regresses, and grey where the difference is within one std dev of the baseline (within noise). Higher is better for throughput and rate, lower for latency and memory. A benchmark which does not exist on Throughput (tx/s)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(2){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(3){fill:#808A94!important}
.radarAxisLabel:nth-of-type(4){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(5){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(6){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(7){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(8){fill:#E5484D!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["Basic Blocking 100ms: 3,013 tx/s ▼ 2%"]
axis b1["Basic Blocking 20ms: 12,578 tx/s ▼ 11%"]
axis b2["Basic Blocking 2ms: 9,444 tx/s ▬ +9%"]
axis b3["Basic JS: 6,747 tx/s ▼ 8%"]
axis b4["FluentD: 12,525 tx/s ▼ 12%"]
axis b5["Historical Queries: 395,549 tx/s ▼ 20%"]
axis b6["L…g Certificate Blocking: 13,200 tx/s ▼ 16%"]
axis b7["Logging JWT Blocking: 10,624 tx/s ▼ 19%"]
curve stddev2_high["main EWMA + 2 std dev"]{103.87, 106.79, 148.93, 109.26, 108.68, 112.37, 112.99, 111.78}
curve stddev1_high["main EWMA + 1 std dev"]{101.93, 103.40, 124.47, 104.63, 104.34, 106.19, 106.50, 105.89}
curve stddev1_low["main EWMA - 1 std dev"]{98.07, 96.60, 75.53, 95.37, 95.66, 93.81, 93.50, 94.11}
curve stddev2_low["main EWMA - 2 std dev"]{96.13, 93.21, 51.07, 90.74, 91.32, 87.63, 87.01, 88.22}
curve branch_0["#8921 (4 runs earlier)"]{97.52, 96.57, 135.84, 92.07, 97.17, 101.11, 93.32, 91.90}
curve branch_1["#8921 (3 runs earlier)"]{97.08, 95.65, 132.43, 94.33, 96.94, 103.12, 94.55, 94.49}
curve branch_2["#8921 (2 runs earlier)"]{97.30, 98.92, 130.54, 97.91, 95.61, 98.32, 93.30, 91.49}
curve branch_3["#8921 (1 run earlier)"]{97.30, 98.02, 134.02, 93.47, 96.43, 99.81, 93.52, 93.94}
curve branch_4["#8921"]{97.87, 88.63, 108.73, 91.57, 87.80, 79.57, 83.55, 80.94}
graticule polygon
max 184
min 16
ticks 0
showLegend false
Latency (ms)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(2){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(3){fill:#808A94!important}
.radarAxisLabel:nth-of-type(4){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(5){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(6){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(7){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(8){fill:#E5484D!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["Basic Blocking 100ms: 98 ms ▼ 1%"]
axis b1["Basic Blocking 20ms: 20 ms ▲ 5%"]
axis b2["Basic Blocking 2ms: 30 ms ▬ -19%"]
axis b3["Basic JS: 43 ms ▲ 5%"]
axis b4["FluentD: 20 ms ▲ 5%"]
axis b5["Historical Queries: 77 ms ▲ 28%"]
axis b6["Logging Certificate Blocking: 38 ms ▲ 11%"]
axis b7["Logging JWT Blocking: 23 ms ▲ 13%"]
curve stddev2_high["main EWMA + 2 std dev"]{100.96, 103.56, 149.84, 107.11, 103.14, 117.70, 107.87, 107.50}
curve stddev1_high["main EWMA + 1 std dev"]{100.48, 101.78, 124.92, 103.56, 101.57, 108.85, 103.93, 103.75}
curve stddev1_low["main EWMA - 1 std dev"]{99.52, 98.22, 75.08, 96.44, 98.43, 91.15, 96.07, 96.25}
curve stddev2_low["main EWMA - 2 std dev"]{99.04, 96.44, 50.16, 92.89, 96.86, 82.30, 92.13, 92.50}
curve branch_0["#8921 (4 runs earlier)"]{99.41, 99.41, 65.06, 105.23, 99.52, 104.64, 96.75, 103.26}
curve branch_1["#8921 (3 runs earlier)"]{99.41, 99.41, 67.78, 102.79, 99.52, 106.30, 96.75, 103.26}
curve branch_2["#8921 (2 runs earlier)"]{99.41, 99.41, 67.78, 100.34, 99.52, 96.33, 99.68, 103.26}
curve branch_3["#8921 (1 run earlier)"]{99.41, 99.41, 65.06, 105.23, 99.52, 102.98, 96.75, 103.26}
curve branch_4["#8921"]{99.41, 104.64, 81.33, 105.23, 104.76, 127.89, 111.41, 113.10}
graticule polygon
max 185
min 15
ticks 0
showLegend false
Memory (bytes)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(2){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(3){fill:#808A94!important}
.radarAxisLabel:nth-of-type(4){fill:#808A94!important}
.radarAxisLabel:nth-of-type(5){fill:#808A94!important}
.radarAxisLabel:nth-of-type(6){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(7){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(8){fill:#808A94!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["Basic Blocking 100ms: 54.6 MiB ▼ 4%"]
axis b1["Basic Blocking 20ms: 59.5 MiB ▼ 3%"]
axis b2["Basic Blocking 2ms: 58.4 MiB ▬ 0%"]
axis b3["Basic JS: 59.6 MiB ▬ -2%"]
axis b4["FluentD: 58.2 MiB ▬ -1%"]
axis b5["Historical Queries: 112 MiB ▼ 2%"]
axis b6["Logging Certificate Blocking: 83.8 MiB ▼ 4%"]
axis b7["Logging JWT Blocking: 57.6 MiB ▬ -1%"]
curve stddev2_high["main EWMA + 2 std dev"]{103.72, 103.96, 102.95, 104.24, 104.81, 102.30, 103.31, 106.38}
curve stddev1_high["main EWMA + 1 std dev"]{101.86, 101.98, 101.47, 102.12, 102.40, 101.15, 101.65, 103.19}
curve stddev1_low["main EWMA - 1 std dev"]{98.14, 98.02, 98.53, 97.88, 97.60, 98.85, 98.35, 96.81}
curve stddev2_low["main EWMA - 2 std dev"]{96.28, 96.04, 97.05, 95.76, 95.19, 97.70, 96.69, 93.62}
curve branch_0["#8921 (4 runs earlier)"]{100.30, 98.12, 101.60, 99.45, 103.81, 97.97, 101.21, 97.42}
curve branch_1["#8921 (3 runs earlier)"]{99.88, 99.21, 97.76, 97.78, 100.21, 98.08, 101.37, 95.17}
curve branch_2["#8921 (2 runs earlier)"]{98.64, 97.57, 96.36, 99.39, 97.66, 97.83, 100.42, 99.67}
curve branch_3["#8921 (1 run earlier)"]{99.81, 99.33, 98.22, 100.21, 101.37, 99.15, 102.45, 95.75}
curve branch_4["#8921"]{95.96, 97.16, 99.92, 98.37, 98.72, 98.47, 95.56, 99.24}
graticule polygon
max 111
min 89
ticks 0
showLegend false
Rate (ops/s)---
config:
radar:
width: 620
height: 620
marginTop: 90
marginRight: 220
marginBottom: 60
marginLeft: 220
axisLabelFactor: 1.12
curveTension: 0.08
theme: base
themeCSS: |
.radarCurve-0{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-1{fill:color-mix(in srgb, #62B5E5 40%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-2{fill:color-mix(in srgb, #62B5E5 13%, var(--color-canvas-default,var(--bgColor-default,#fff)))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarCurve-3{fill:var(--color-canvas-default,var(--bgColor-default,#fff))!important;fill-opacity:1!important;stroke:none!important;stroke-width:0!important}
.radarAxisLabel,.radarTitle{fill:var(--color-fg-default,var(--fgColor-default,#111827))!important;color:var(--color-fg-default,var(--fgColor-default,#111827))!important}
.radarCurve-4{stroke-width:1.5px!important;stroke-opacity:0.20!important}
.radarCurve-5{stroke-width:1.5px!important;stroke-opacity:0.30!important}
.radarCurve-6{stroke-width:1.5px!important;stroke-opacity:0.40!important}
.radarCurve-7{stroke-width:1.5px!important;stroke-opacity:0.50!important}
.radarCurve-8{stroke-width:1.75px!important;stroke-opacity:1.00!important}
.radarAxisLabel:nth-of-type(1){fill:#808A94!important}
.radarAxisLabel:nth-of-type(2){fill:#2DA44E!important}
.radarAxisLabel:nth-of-type(3){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(4){fill:#808A94!important}
.radarAxisLabel:nth-of-type(5){fill:#808A94!important}
.radarAxisLabel:nth-of-type(6){fill:#808A94!important}
.radarAxisLabel:nth-of-type(7){fill:#808A94!important}
.radarAxisLabel:nth-of-type(8){fill:#E5484D!important}
.radarAxisLabel:nth-of-type(9){fill:#808A94!important}
themeVariables:
cScale0: "#62B5E5"
cScale1: "#62B5E5"
cScale2: "#62B5E5"
cScale3: "#62B5E5"
cScale4: "#F97316"
cScale5: "#F97316"
cScale6: "#F97316"
cScale7: "#F97316"
cScale8: "#F97316"
radar:
axisColor: "#9CA3AF"
graticuleColor: "#E5E7EB"
graticuleOpacity: 0
axisStrokeWidth: 1
curveOpacity: 0
---
radar-beta
axis b0["CCF c…n c…t lifecycle: 13,280 ops/s ▬ -1%"]
axis b1["CCF fresh JS invocation: 12,585 ops/s ▲ 2%"]
axis b2["CHAMP get: 37,854,423 ops/s ▼ 8%"]
axis b3["CHAMP put: 5,391,716 ops/s ▬ -1%"]
axis b4["KV deserialisation: 2,380,952 ops/s ▬ -3%"]
axis b5["KV serialisation: 1,960,784 ops/s ▬ -1%"]
axis b6["KV s…t deserialisation: 4,491 ops/s ▬ 0%"]
axis b7["KV snapshot serialisation: 5,184 ops/s ▼ 16%"]
axis b8["Q…S s…d c…t lifecycle: 15,737 ops/s ▬ -1%"]
curve stddev2_high["main EWMA + 2 std dev"]{102.88, 102.92, 112.36, 102.24, 105.84, 102.92, 104.39, 112.09, 102.32}
curve stddev1_high["main EWMA + 1 std dev"]{101.44, 101.46, 106.18, 101.12, 102.92, 101.46, 102.20, 106.05, 101.16}
curve stddev1_low["main EWMA - 1 std dev"]{98.56, 98.54, 93.82, 98.88, 97.08, 98.54, 97.80, 93.95, 98.84}
curve stddev2_low["main EWMA - 2 std dev"]{97.12, 97.08, 87.64, 97.76, 94.16, 97.08, 95.61, 87.91, 97.68}
curve branch_0["#8921 (4 runs earlier)"]{100.04, 98.65, 92.23, 99.71, 97.30, 101.13, 100.40, 101.38, 98.30}
curve branch_1["#8921 (3 runs earlier)"]{103.27, 100.88, 91.72, 100.53, 97.30, 97.25, 100.74, 92.42, 100.14}
curve branch_2["#8921 (2 runs earlier)"]{98.14, 99.48, 92.06, 101.92, 88.84, 97.25, 101.85, 98.26, 97.66}
curve branch_3["#8921 (1 run earlier)"]{97.00, 97.42, 91.38, 99.63, 99.68, 101.13, 103.64, 98.31, 98.31}
curve branch_4["#8921"]{99.34, 101.64, 91.71, 99.31, 97.30, 99.15, 100.00, 83.84, 98.88}
graticule polygon
max 123
min 73
ticks 0
showLegend false
|
Port the role-lock tests to forbidden live signature-table access: reserved transactions now write signatures, and next_txid() callers added on main unwrap its optional result. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70f21073859b499a96d2c66cab082118
There was a problem hiding this comment.
🔵 Needs a closer look
Consensus/KV rollback and lock-order changes require human concurrency review and runtime validation of unverified demotion, retirement, and follower-replication interleavings.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

A node that steps down can still have local writers in flight: RPC transactions,
emit_signature(), and Snapshotter evidence transactions.Store::commit()publishes to the KV and the Merkle history beforereplicate()checks leadership, while followerexecute_append_entries_sync()holds the consensus lock but notcommit_lock. A stale leaf can therefore land in a follower's history. That makes the follower NACK validAppendEntries(seen in CI asverify_root_signaturesfailing indeserialise.h). Worse, the stale writer'srollback(last_idx)inreplicate()can retract the leader's entry while keeping the stale one, leaving the follower permanently diverged.sequenceDiagram participant W as Stale local writer participant H as Merkle history (stepped-down node) participant F as Aft (now follower) participant L as New leader Note over F: Leader in term T, last_idx = N-1 W->>W: RPC passes can_replicate(), applies writes at version N, term T L->>F: message with term T+1 F->>F: become_aware_of_new_term(): becomes follower, Store not rolled back W->>H: Store::commit() appends stale leaf (leaf N), no leadership check yet L->>F: AppendEntries with entry N F->>H: append leader's entry N (lands as leaf N+1) F->>L: ACK last_idx = N W->>F: replicate(): not leader F->>H: rollback(last_idx = N) truncates to N leaves Note over H: Leader's leaf removed, stale leaf N kept.<br/>Merkle root diverges, later signatures fail to verify (NACK)In short: discarding a stepped-down node's speculative local state moves from whichever stale writer reaches
replicate()to the demotion itself, and a role lock makes that discard final.update_local_writes(), which every leadership change goes through. When writes close, it rolls back tolast_idx(the end of Aft's own log, committed or not) there, under its own lock.replicate()no longer rolls back; a stale writer that reaches it is simply refused, because its entries were already discarded at demotion, or carry an old term if the node has since been re-elected (every candidacy increments the view).Storerequests from its consensus: once whileCommittableTx::commit()applies the writes, and once whileStore::commit()publishes them to the history, released beforereplicate(). Each permit rechecks that writes are open, andStore::commit()also rejects a transaction if a rollback has discarded state since it was applied. Closing writes takes the lock exclusively just long enough to flip the flag, so demotion waits for writers holding a permit; the rollback follows, and once writes are closed later writers are refused before they touch the KV or history, so nothing can be added to the discarded suffix.commit()closes writes once compaction is done, still under the consensus lock, so nothing published in between can be replicated.Storewith no consensus, or a non-Aft one, accepts local writes unfenced, as before. Read-only transactions on backups are unaffected, unless they request a snapshot, which only a primary can act on.With the fix, the same interleaving:
sequenceDiagram participant W as Stale local writer participant H as Merkle history (stepped-down node) participant F as Aft (now follower) participant L as New leader Note over F: Leader in term T, last_idx = N-1 W->>F: permit 1 (role lock shared) W->>W: CommittableTx::commit() applies writes at version N, term T L->>F: message with term T+1 F->>F: become_aware_of_new_term(): becomes follower, update_local_writes() waits for permit 1 W-->>F: release permit 1 F->>F: close local writes, rollback(last_idx = N-1) discards version N W->>F: Store::commit() asks for permit 2 F-->>W: refused, FAIL_NO_REPLICATE, nothing appended L->>F: AppendEntries with entry N F->>H: append leader's entry N (leaf N) F->>L: ACK last_idx = N Note over H: History matches the leader'sThe fix also closes two related gaps:
Store::commit()now checks the rollback count and term before appending to history, under the same lock as rollback.Safety and compatibility
Consensus/KV change. Lock order is
commit_lock -> consensus lock -> role_rwlock -> maps_lock -> version_lock -> history lock; the role lock is never held acrossreplicate()or taken recursively. An atomic pending flag refuses new local writers while a role change waits for the lock, so a stream of new writers cannot starve demotion on a reader-preferringshared_mutex.next_txid()now returnsstd::optionaland is empty on a node that does not accept local writes. Client writes refused because of a step-down fail with the existingTransactionReplicationFailederror, as they could before. The fix prevents divergence; it does not repair a node that has already diverged.The trace-validation impact of moving the rollback from
replicate()to step-down has not been checked locally (cft_trace_e2ewas not run).Alternatives
replicate(), as a Lean model of the protocol suggested. It isn't needed: the view strictly increases before any re-promotion, so the existing term check already rejects stale writers.replicate(). It would deadlock with demotion, which holds the consensus lock while waiting for the role lock. Taking the consensus lock for all ofStore::commit()instead would close the gap, but would put hashing and signing under it.Store, with Aft enabling and disabling local writes at each transition. Dropped because writability then had to be kept in sync by hand at every call site.