Skip to content

3.x.x: inject faults under load in a load-harness fault phase, per PR and nightly on the real node (#554) - #623

Merged
djh58 merged 2 commits into
3.x.xfrom
djh58/prism-b554-faults2
Sep 30, 2026
Merged

djh58 merged 2 commits into
3.x.xfrom
djh58/prism-b554-faults2

Conversation

@djh58

@djh58 djh58 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Refs #554 (#487 S16). This is the first of two PRs, as agreed in the design on #554: the fault injector and seven of the faults. The second PR adds the primary kill with async promotion, a block mid-landing across failover, a full WAL disk and a restart over a candidate backlog, on #588's weekly selection. No server code changes.

What

qbit-prism-load --faults <fault>[,<fault>...][;<key>=<value>...] adds a faults side phase after every other phase (src/fault/). Each fault runs while the sessions keep mining, in this order: a baseline window, the injection (held for hold s, or, for a restart, until the frontend serves again), the removal and a recovery window. The driver is polled from the scheduling loop, as the drained restart and the mid-flight kill are, so the other sessions keep getting load. The phase ends when the last fault has recovered.

Each fault is held to its criteria, on top of the run's own contract: every acknowledged share is in PostgreSQL, no committed share goes unanswered mid-run, and one submitblock per block hash.

Fault What is injected Pass criteria
slow-database The delay proxy holds every chunk for --slow-db-delay-ms. The delay is seen on the frontends' own URL. No frontend exits. The second half of the recovery window offers the full rate, with ACK p99 within max(--ack-p99-limit-ms, 2 × the baseline's).
pool-exhaustion Every free PostgreSQL slot is taken, and the frontends' idle backends are terminated into the full server. Managed cluster only. PostgreSQL refused a connection (53300), and at least one frontend backend was terminated. Recovery as above. The frontends' pool-acquire outcomes are recorded.
settlement-lock An outside transaction holds SETTLEMENT_LOCK, and a tip is minted halfway through. No share waits on the holder. At least 90 % of shares are accepted until the refresh has been stalled for PRISM_SUBMIT_TIP_MAX_AGE_SECONDS. After that the server refuses shares it cannot prove current, as designed; those refusals are counted, not failed. No session gets work on the tip before the release, and every session has it within 10 s of the release. ACK p50, p99 and max over the hold are recorded.
frontend-sigkill A scheduled block's submitblock is forwarded and its reply withheld. The offering frontend is then killed and relaunched, with the mid-flight kill's census and re-offers. The block reaches the node exactly once and lands without a second offer. The time to land is reported and not gated: it is the candidate lease, #529's option-A gap that #585 left open.
sigterm-drain A scheduled block's submitblock is held 500 ms, and the offering frontend gets SIGTERM as the call arrives. The shutdown logs that it waits for the offer, with no budget ALERT. The frontend exits 0 within 35 s. The block reaches the node once. accepted is recorded on the candidate before the process exits (#578, #585).
rolling-restart Each frontend in turn gets SIGTERM, its sessions move to the other, and it is relaunched. The sessions are then rebalanced. Every exit is 0 within 35 s, and every moved session has work within 30 s.
reconnect-storm A fraction of the sessions (storm, 0.5) drop abruptly and come back within 5 s. Every stormed session has work within 10 s of its return.
read tier (all through the phase) A separate public-api process on the standby, polled at 5 requests/s across pool-summary, blocks, leaderboard and hashrate-series, and every frontend's /metrics every 5 s. The public API answers at least 99 % 2xx with p99 at most 1 s, excluding only the pool-exhaustion window, which denies its pool too. Every live frontend's /metrics answers within 1 s (#189's class, #469).

The API for #556:

  • order=random draws count faults with a seeded stream, with gap=<min>..<max> between them. The drawn sequence is in the report, so a failed soak replays.
  • The keys are baseline, hold, recovery, read-tier, storm and lease-wait.

The relay. A per-frontend JSON-RPC relay sits in front of the node, fake or real. It can hold the next submitblock for a set time, or forward it and withhold the reply. Each call is carried by its own task, so a frontend that gives up on a call does not cancel it. Only a run with a fault phase launches its frontends on the relay; every other run's node path, and its side report's keys, are unchanged.

The verdict is the side report's faults block. It has one row per fault, with:

  • its windows;
  • the shares offered in the baseline, during the fault and in the second half of recovery, with the refusals by reason;
  • its evidence;
  • each check.

Exit 9 is new: a fault that missed a criterion in a run that otherwise reconciled. The gate prints one row per fault and one for the read tier.

Where it runs, and what it costs

Preset Lane Runner What Cost
faults-pr-smoke per PR: gated qbit-prism-load::faults::…, shard 1 of 4 beside real_node 2 vCPU 1 debug frontend, 40 sessions, fake node: sigterm-drain and settlement-lock About 35–41 s per PR here (34–41 s over five runs; the nested server build is a no-op, below). Expect more on the 2-vCPU runner.
faults-short-real-node nightly (the existing matrix picks it up; no workflow change) 8 vCPU, 45 min cap 2 frontends, async standby, 500 sessions at 50 shares/s on the real node, all seven faults plus the read tier About 9 min of run (510–532 s here) plus the shared build: about $0.15–0.20 a night, about $5 a month (the cap is $0.72 a night)

The weekly long set, with 2,000 sessions and the PR2 faults, comes with PR2 on #588's weekly selection.

tests/faults.rs builds the server the way #617 now has load_smoke, real_node and soak_smoke do: with -p qbit-prism-load selected too, and without the variables cargo test sets for the test process (CARGO_PKG_*, CARGO_MANIFEST_* and the rest), which ring's build script tracks. The nested build is then 0.1 s instead of about 21 s.

Adding the faults test target shifts run_rust_test_shard.py's round-robin assignment for the targets after it, as any new test binary does.

Changes outside src/fault/

  • run.rs: the relay's URL for each frontend (fault runs only), the phase hook, the frontend-exit check skipping a planned outage, the verdict and exit 9.
  • cli.rs / preset.rs: --faults, with null meaning off. Every preset pins "--faults": null; that one line is its only change.
  • node.rs: MintPurpose::Fault.
  • gate.rs: the per-fault rows.
  • check_e2e_scenarios.py knows the faults binary as a scenario and smoke binary, with a fixture test.
  • test/e2e-scenarios.toml: the 3.x.x: Fault injection under load (L4/L5) (#487 S16) #554 placeholders become eight running entries, one per fault plus the read tier, each with its criteria, and four planned PR2 entries.
  • README.md: a section on the faults, and exit 9.

Tests and mutants

Checks run:

Mutants. Each was applied to the server, built, run and reverted. M2 was run again on the final tree.

Mutant Run Result
M1: a shutdown drops the offer in flight at once (#578's old cancellable path) gated faults test FAILED: the shutdown waited for the offer (not logged) and the node's answer was recorded before the process exited (row left offer_reserved)
M2: the share append also takes SETTLEMENT_LOCK gated faults test FAILED: no share waited on the lock holder (ACK p99 5.2 s) and shares on retained work accepted… (19 of 40 accepted, 21 ledger-confirmation-failed); exit 9
M3: a recovered offer_reserved row calls submitblock again (#531's M1) frontend-sigkill on the fake node exit 9: the block reached the node exactly once (forwarded twice)

The nightly preset on the real node (a debug build on a shared host with 1-minute load 2–6.5) exited 0 twice, in 510 s and 532 s. Every fault passed, and the public API answered 2,139 of 2,139 requests with p99 48 ms. On the final tree it ran once more the way the nightly does (prism-load-run.sh, release builds, 1-minute load about 12): gate PASS in about 9 min, every fault passed, and the public API answered 2,027 of 2,027 with p99 74 ms. What the first two runs measured:

  • frontend-sigkill: the block landed 124–144 s after the kill (the candidate lease), exactly once.
  • sigterm-drain: exit 0.53 s after SIGTERM, with accepted recorded.
  • settlement-lock (30 s): ACK p50 5.4 ms, p99 71 ms, max 298 ms. 49 of 1,500 shares were refused backend-rpc-unavailable once the stall passed the tip's max age.
  • slow-database at 20 ms one way: 438 of 1,336 shares accepted and the rest refused truthfully (ledger-confirmation-failed 518, backend-rpc-unavailable 380). Nothing was lost and there was no divergence: this is the 3.x.x: The 2,000 shares/s burst ceiling is about a fifth lower on a1937054 than on 5d0042f6, same host #479 ceiling.

Not covered here

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

… and nightly on the real node (#554)

--faults adds a `faults` side phase to qbit-prism-load in which each named
fault is injected while the sessions keep mining, then held to its #554 pass
criteria on top of the run's own reconciliation. A fault that misses one
exits 9, and the gate shows one row per fault. No server code changes.

The faults: a slow database through the delay proxy, PostgreSQL at
max_connections with the frontends' idle backends terminated, a long
SETTLEMENT_LOCK holder with a tip minted during the hold, SIGKILL of the
frontend holding a block the node accepted, SIGTERM of a frontend with a
found block's offer in flight, a rolling restart of both frontends, and a
reconnect storm. A public-api process on the standby and every frontend's
/metrics are scraped throughout. A per-frontend JSON-RPC relay, used only
when a fault phase is asked for, holds or withholds a scheduled block's
submitblock so the offer is in flight at a known moment.

faults-pr-smoke runs the SIGTERM drain and the settlement-lock holder per
PR on the fake node (tests/faults.rs, gated). faults-short-real-node runs
all seven nightly on the real node with 500 sessions. The plan can be
randomised and seeded for #556's soak. Every preset pins --faults, the
manifest names each fault with its criteria, and check_e2e_scenarios.py
knows the faults test binary.

Refs #554

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@djh58
djh58 requested a review from kiwidream September 30, 2026 19:54
…checks that could pass without testing anything (#554)

Review of the fault phase found checks that could pass without testing
what they name, plus cleanup and timing gaps. No server code changes.

Checks that could pass without testing anything:
- settlement-lock on the real node took the first tip change after the
  mint request as the fault's tip, so a keepalive or found block could
  stand in for it. It now uses the fault's own mint as the pool node saw
  it. A tip that reached the pool node only after the release fails "the
  tip's jobs waited for the release" instead of passing on zero sessions.
- "no share waited on the lock holder" now covers the whole hold, not only
  the time up to the mint. A refresh that queued for the holder while
  holding ORDER_LOCK would stall shares only after the mint.
- frontend-sigkill waited up to 20 s for outstanding shares before the
  kill. By then the frontend's 1 s submitblock deadline could have
  recorded the call as unknown, so its answer was no longer what the kill
  lost. The kill now comes at once. The check requires it inside that
  deadline and requires the node to have accepted the block, since a
  rejection or an RPC error is also an answer. The kill's census of
  re-offers is in the evidence; possible losses are reported, not gated,
  as for the mid-flight kill.
- With the public API on the standby, the pool-exhaustion window is no
  longer excluded from its figures; that fault takes only the primary's
  slots.
- --faults is refused under --plan soak and in a soak's looped presets
  until #556, where the verdict would otherwise go missing.

Ordering, cleanup and timing:
- The faults phase now runs after every other phase, as documented. The
  phase used to come before mid_flight_kill, so a fault cut short by the
  phase bound could leave a frontend down for that phase to report as a
  crash.
- The phase bound gives rolling-restart one allowance per frontend.
- The settlement-lock /metrics sampler stops when its recovery window
  closes.
- The read tier starts before the phase's clock, so the per-second
  buckets line up with the fault windows.
- The lock's release is stamped as ROLLBACK is sent.
- A finished task's handle is polled in place, so a Pending cannot drop
  its result.
- A lock holder that fails before taking the lock reports its own error.
- The relay forwards to the node's origin plus the path the call came in
  on, instead of doubling a node URL path.

The new unit tests pin the phase order (they fail on the old order), the
rolling-restart bound, the soak refusal and what counts as an accepted
block. faults-pr-smoke passes in 33-34 s, as before (no added per-PR
cost).

Refs #554

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@djh58

djh58 commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Review ledger: #623 (Refs #554)

Lanes run

  • /code-review high, which reported 10 findings.
  • One independent adversarial review. It looked at four questions: can a fault's verdict pass while the pool lost an acknowledged share or double-submitted a block; is the injector cleaned up on failure; is it flaky under a loaded runner; and what does it cost per PR. It reported 13 findings, several overlapping the first lane's.

Every finding was checked against the code. The fixes are in one follow-up commit, 2a81d96.

Fixed

# Finding Fix
1 cli.rs put the faults phase before mid_flight_kill, although the docs say it runs after every other phase. If the phase bound cuts a frontend fault short, the frontend can stay down, and the following mid_flight_kill phase reports it as an unexpected exit. It can also aim its own kill at that frontend. faults is now pushed last. A unit test pins the order for the short and tips plans, and fails on the old order.
2 settlement-lock on the real node took the first tip change of any kind after the mint request as the fault's tip, so a keepalive or found block could stand in for it. A tip that reached the pool node only after the release passed "the tip's jobs waited for the release" on zero sessions. The verdict uses the fault's own MintPurpose::Fault mint, as the pool node saw it. A tip that arrives after the release fails the check and says why.
3 "No share waited on the lock holder" only covered the time up to the mid-hold mint. A refresh that queued for the holder while holding ORDER_LOCK would stall shares only after the mint. The answer p99 is now gated over the whole hold. The 90 % window is unchanged.
4 frontend-sigkill used the mid-flight kill's wait of up to 20 s for outstanding shares. By then the frontend's 1 s submitblock deadline could already have recorded the call as unknown. "Held a found block the node had accepted" was also satisfied by any answer, including a rejection or an RPC error. The kill now comes at once (KillDriver::without_work_wait). The check requires the kill inside the 1 s deadline and requires the node to have accepted the block (null result, no error).
5 When the public API reads the standby, the pool-exhaustion window was still excluded from its figures, although that fault takes only the primary's slots. The window is excluded only when the public API reads the primary.
6 Under --plan soak, or in a soak's looped presets, --faults would produce a fault phase with no verdict, or overwrite the verdict each cycle. --faults is refused in both places until #556.
7 The settlement-lock /metrics sampler ran until the end of the run. It stops when its recovery window closes.
8 The read tier's start-up was awaited after the phase's clock started, so the verdict read the per-second buckets offset by the start-up time. The read tier and the driver start before the phase's clock.
9 The phase bound allowed rolling-restart two turns whatever the number of frontends. It now allows one turn per frontend, with a unit test.
10 The lock release was stamped after ROLLBACK returned. A session that got the tip in that gap counted as served during the hold, which could flake on a loaded runner. The release is stamped as ROLLBACK is sent.
11 A finished task's handle was taken before it was polled, so a Pending from the task budget dropped the result. The handle is polled in place.
12 A lock holder that failed before taking the lock could report "no reason given". The verdict waits for the task to finish, so its own error is the reason.
13 The relay forwarded to the full node URL with the incoming path appended, which doubles a path. This cannot happen with today's node URLs. The relay forwards to the node's origin plus the incoming path and query, with a unit test.
14 The fault SIGKILL's re-offer census was not reported anywhere. It is now in the fault's evidence. Possible losses are reported but not gated, the same rule as mid_flight_kill.

Rejected

  • abandon() leaves an interrupted frontend fault unfinished. This happens only on a path that already fails the fault ("the phase ended before this fault finished"). With faults last, no phase follows to misread it. Relaunching inside abandon would add a second restart path for no verdict gain.
  • tests/faults.rs is a fourth copy of build_server. It follows the pattern 3.x.x: remove Config::block_only_ack_timeout, share the mature-CTV-fanout fixture, and stop the load tests rebuilding the server's dependencies (#579, #580) #617 used for load_smoke, real_node and soak_smoke. Consolidating the copies into a shared module touches other suites' files, so it belongs in a follow-up.
  • Surface a JoinError from Spawned. None of the spawned tasks has a panicking path. A stuck task is bounded by the phase bound and reported as not finished.
  • Start the read tier with the frontends rather than before the phase. Resolved by fix 8: the start-up now happens before the phase's clock, so the fault windows are not affected.
  • FaultTools copies of plan fields. A nit with no behaviour change.

Verification

  • cargo fmt, and cargo clippy -p qbit-prism-load --all-targets -D warnings.
  • qbit-prism-load unit tests: the lib's 35, harness 138, churn, soak_plan and realism.
  • check_e2e_scenarios.py and its tests.
  • The gated faults test on PostgreSQL 16 with fsync on and PRISM_TEST_REQUIRE_INTEGRATION=1 passed 3 of 3, in 34.4, 33.5 and 33.4 s. That is the same per-PR cost as before; this commit adds none.
  • faults-short-real-node, run the way the nightly runs it (release builds, real node): exit 0 and gate 0, with all seven faults passing.
    • frontend-sigkill killed the frontend 5 ms after the call. The node had accepted the block, which reached it once and landed after the 120 s lease.
    • settlement-lock had an answer p99 of 4.5 ms over the whole hold.
    • The public API answered 2,201 of 2,201 requests with p99 40 ms. That now includes the pool-exhaustion window, since it reads the standby.
  • Mutant: the phase-order test fails against the PR's original order (["…", "churn", "faults", "mid_flight_kill"]).

@djh58
djh58 merged commit b7bbbbe into 3.x.x Sep 30, 2026
30 checks passed
Anatolie added a commit that referenced this pull request Sep 30, 2026
Brings in #623's --faults (pinned null in every preset), #615's ORDER_LOCK
hold measurements and the other 3.x.x commits since 72efbcb/1932cb30.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Anatolie added a commit that referenced this pull request Sep 30, 2026
…#511)

#623 added --faults and pinned it null (no fault phase) in every preset,
so every preset stopped resolving against 5d0042f, which has no such
flag. A build older than the flag ran no fault phase, which a pinned null
still means, so legacy-flags.json now says so (introduced at b7bbbbe).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke added a commit that referenced this pull request Oct 6, 2026
… preset flags, and document L3 in the lanes page (#550)

#608 was stacked on an earlier #564. Since then #564's
`compare::Build` gained `predates_report_fields`. A collation
summarizes one build, the plan's commit, which predates no report field,
so the list is empty.

3.x.x added two result flags every checked-in preset must pin:
`--ctv-settlement` (#644) and `--faults` (#623). The three new presets
pin `false` and `null`, as the presets they derive from do, so each
differs from its source only in `--cadence` and `--scheduled-blocks`
(and the dense 1-frontend cell in its runner and schedule).

docs/prism-e2e-load-ci.md did not exist on #608's base. It now has
#626's L3 section: the lane table's row, the suites and triggers, what
L3 proves and does not, the dispatch commands and the evidence rows.
One correction to the draft: dispatch, like the weekly schedule, needs
the workflow file on `main`, so the status says L3 runs on pull
requests and tags until the file is mirrored there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke added a commit that referenced this pull request Oct 6, 2026
… them in the lanes page, and note that #548 has landed (#555)

3.x.x added two result flags every checked-in preset must pin:
`--ctv-settlement` (#644) and `--faults` (#623). The two session
points pin `false` and `null`, as `throughput-400k-window-2fe-async`
does, so they still differ from it only in `--sessions` and
`--stratum-max-pending-initial-jobs`.

#548 (CTV fanout settlement in the harness) landed as #644. The
10,000-recipient point still has no preset, but the README, the suite
comment and the scenario manifest now say it can be written with
`--ctv-settlement` on, rather than that it waits on #548. The
50,000-recipient trigger is evaluated once that preset runs.

docs/prism-e2e-load-ci.md gets #626's parts for this change: the
`l3-reduced` row's nine presets, its cost of about 200 runner-minutes a
week, and the capacity-envelope paragraph.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke added a commit that referenced this pull request Oct 6, 2026
… preset flags, and document L3 in the lanes page (#550)

#608 was stacked on an earlier #564. Since then #564's
`compare::Build` gained `predates_report_fields`. A collation
summarizes one build, the plan's commit, which predates no report field,
so the list is empty.

3.x.x added two result flags every checked-in preset must pin:
`--ctv-settlement` (#644) and `--faults` (#623). The three new presets
pin `false` and `null`, as the presets they derive from do, so each
differs from its source only in `--cadence` and `--scheduled-blocks`
(and the dense 1-frontend cell in its runner and schedule).

docs/prism-e2e-load-ci.md did not exist on #608's base. It now has
#626's L3 section: the lane table's row, the suites and triggers, what
L3 proves and does not, the dispatch commands and the evidence rows.
One correction to the draft: dispatch, like the weekly schedule, needs
the workflow file on `main`, so the status says L3 runs on pull
requests and tags until the file is mirrored there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke pushed a commit that referenced this pull request Oct 6, 2026
…didate, v* tags and weekly (#550) (#608)

Refs #550 (S5 of #487). prism-load-l3.yml runs #447's
production-window matrix as checked-in suites
(crates/qbit-prism-load/presets/suites.toml):
- l3-full: 11 cells x 3 repeats on the 32 vCPU class. It runs on a
  same-repository PR that changes VERSION, on the release-candidate
  label, on a v* tag and on dispatch.
- l3-reduced: 400k at 1, 2 and 4 frontends, weekly on 3.x.x.

#473's found-block and dense-cadence cells become presets.
qbit-prism-load-compare --collate renders one build's suite into #473's
tables with #511's summarizer. It writes a complete/passed verdict, and
lists any missing, foreign or edited run as failing the suite rather
than dropping it. A tag promotes the newest finished same-repository
PR run of l3-full whose verdict is complete for the tagged tree
(scripts/prism_l3_promote.py), and carries that verdict; otherwise it
runs the suite. check_e2e_scenarios.py gains a suites evidence key
beside 3.x.x's lane_checks.

Taken over per #626 and restacked onto 3.x.x after #564. The new
presets pin --ctv-settlement false and --faults null, as every preset
must since #644 and #623. collate fills #564's predates_report_fields.
docs/prism-e2e-load-ci.md gets #626's L3 section, which notes that
dispatch and the weekly run need the file on main. Spend: once this is
on 3.x.x, a v* tag or a VERSION-changing PR starts l3-full (about
$42); the coordinator accepted that for the release-candidate bump.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RobertClarke added a commit that referenced this pull request Oct 6, 2026
… them in the lanes page, and note that #548 has landed (#555)

3.x.x added two result flags every checked-in preset must pin:
`--ctv-settlement` (#644) and `--faults` (#623). The two session
points pin `false` and `null`, as `throughput-400k-window-2fe-async`
does, so they still differ from it only in `--sessions` and
`--stratum-max-pending-initial-jobs`.

#548 (CTV fanout settlement in the harness) landed as #644. The
10,000-recipient point still has no preset, but the README, the suite
comment and the scenario manifest now say it can be written with
`--ctv-settlement` on, rather than that it waits on #548. The
50,000-recipient trigger is evaluated once that preset runs.

docs/prism-e2e-load-ci.md gets #626's parts for this change: the
`l3-reduced` row's nine presets, its cost of about 200 runner-minutes a
week, and the capacity-envelope paragraph.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant