Skip to content

3.x.x: take the settlement-lock fault's lock only on current work and a quiet cluster, whichever fault landed a block before it (#692) - #699

Merged
RobertClarke merged 5 commits into
3.x.xfrom
RobertClarke/692-settlement-lock-current-work
Oct 6, 2026
Merged

RobertClarke merged 5 commits into
3.x.xfrom
RobertClarke/692-settlement-lock-current-work

Conversation

@RobertClarke

@RobertClarke RobertClarke commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #692 (close by hand: base is not the default branch).

#691 made the SIGTERM drain wait until its block had landed and every frontend served work at the payout revision the landing committed. Other faults land a block too: frontend-sigkill, block-failover and candidate-backlog. None of them waits for the republication. A settlement-lock straight after one took SETTLEMENT_LOCK while the landing's work was still unpublished, and blocked that publication as well. Every retained-work share in the first half of its hold was then refused stale-job, the same failure as #686.

What changes

Before the lock. The settlement-lock fault waits, from the start of its injection, until both of these hold:

  • every frontend is ready, publishes payout_state_generation equal to the cluster's payout_revision, and has delivered that work to every authorized session;
  • no backend holds or waits for SETTLEMENT_LOCK (a quiet cluster), so the holder is not queued behind a rebuild, a job build or a landing still settling.

The wait is bounded at 60 s, and the phase's time bound includes it. A cluster that never goes quiet gets the lock at the bound anyway.

A found block that has yet to land does not hold the wait. Every bump of the payout revision takes SETTLEMENT_LOCK, so a landing cannot move the revision under the lock.

Under the lock. The holder reads the payout revision in its own transaction; that is the revision the whole hold keeps. Then the fault reads every frontend's /healthz once more before the hold starts. A tip that reached the frontends after the last reading leaves the revision as it was, but not their work, so this reading catches it.

The verdict. A new check, "every frontend served work at the revision the lock kept", passes only if every frontend was ready and publishing work at that revision under the lock. The evidence records:

  • when the cluster was quiet, and how long after the injection started;
  • the last reading before the lock;
  • the revision under the lock, and any error reading it;
  • the reading under the lock.

The hold's ACK summary is now taken from the lock's acquisition, not from the injection's start.

The shared wait. The wait is the drain's work half, moved into a WorkCurrentWait that both faults use; the drain keeps #691's condition. A read still in flight is cancelled when the bound passes or the phase ends. Unit tests cover:

  • current work, and reading again only after the interval;
  • a failed or lost read being replaced;
  • a settlement under way holding only the quiet wait;
  • a reading past the bound;
  • a read in flight at the bound or abort;
  • the reading under the lock ignoring a session still waiting for its first job.

Scope. Only the harness changes, in crates/qbit-prism-load, plus the README fault table and the fault-settlement-lock-holder criteria in test/e2e-scenarios.toml. There is no server change.

Evidence

The loops ran a preset copy with frontend-sigkill,settlement-lock;baseline=0;hold=6;recovery=4: the SIGKILL's block lands through the candidate lease, and the lock comes straight after. As in faults-pr-smoke, that is one debug frontend, 40 sessions and the fake node. Each loop was pinned to two CPUs.

Version Settlement-lock result Notes
Before (c95febb3) Failed in 8 of 8 runs All 8 reported "0 of 60 offered in the first 3.0 s of the hold were accepted (refusals: stale-job 60)"
Current work only (508a7523) Passed in 4 of 5 The failure was a holder queued 1.75 s behind a server settlement right after the republication, with a hold answer p99 of 1.43 s. The one before-run that also failed "no share waited" had queued 0.48 s the same way
Quiet cluster, unfinished candidates counted (9fad6fc2) Passed in 16 of 16 Quiet 1.8–2.8 s after the injection started; lock taken within 0.01 s; hold ACK p99 9–20 ms
Quiet cluster, landings allowed (890bd528) Passed in 10 of 10 Quiet 1.8–3.3 s after the injection started; hold ACK p99 12–31 ms
Final: work re-read under the lock (c41618f8) Passed in 10 of 10, every run exit 0 Quiet 1.3–2.8 s after the injection started; lock queued at most 0.02 s; hold ACK p99 9–19 ms; under the lock, every frontend served revision 4

One 890bd528 run failed its frontend-sigkill fault, whose block offer never reached the relay; its settlement-lock passed. One before-run failed the same way, so it is independent of this change.

A real-node check ran pool-exhaustion,settlement-lock;baseline=10;hold=30;recovery=20: two frontends, 500 sessions, regtest qbitd, as faults-short-real-node. The settlement-lock passed at 9fad6fc2, 890bd528 and c41618f8. Each time the cluster was quiet at once and the lock kept revision 3. Hold p99 was 506, 171 and 11 ms. At c41618f8, every frontend served work at revision 3 under the lock.

cargo test -p qbit-prism-load passes on 9fad6fc2, 890bd528 and the head c41618f8, including faults_under_load_drain_an_offer_in_flight_and_outlast_a_settlement_lock_holder. On the head, cargo clippy --all-targets -D warnings and scripts/check_e2e_scenarios.py are clean.

🤖 Generated with Claude Code

RobertClarke and others added 2 commits October 5, 2026 22:37
… serves current work, whichever fault landed a block before it (#692)

#691 made the SIGTERM drain wait, before the next fault, until its block
had landed and every frontend served work at the payout revision the
landing committed. Other faults land a block too: frontend-sigkill,
block-failover and candidate-backlog. None waits for the republication,
so a settlement-lock straight after one took SETTLEMENT_LOCK while the
landing's work was still unpublished, blocked that publication as well,
and every retained-work share in the first half of its hold was refused
stale-job, the same failure as #686.

The settlement-lock fault now waits, from the start of its injection,
until every frontend is ready, publishes payout_state_generation equal to
the cluster's payout_revision, and has delivered that work to every
authorized session. Only then does it start the lock holder. The wait is
bounded at 60 s; the phase's time bound includes it, and the holder starts
anyway once it passes. A new check fails the fault when the lock had to be
taken without current work, and the evidence records when the work was
current and the last reading. The ACK summary over the hold is now taken
from the lock's acquisition rather than the injection's start.

The wait is the drain's work half, moved into a WorkCurrentWait that both
use, with unit tests for its states: current, read again after the
interval, a failed or lost read replaced, a reading past the bound, and a
read still in flight at the bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the revision it keeps (#692)

Review follow-ups. The settlement-lock fault's wait now also needs no
unfinished found block and no backend holding or waiting for
SETTLEMENT_LOCK. A landing still to come would bump the revision again
mid-hold, and a holder queued behind a settlement under way started its
hold in the middle of it: in one local run that queueing (1.75 s) left
the hold's answers at a p99 of 1.4 s. The holder reads the payout
revision in its own transaction once it has the lock; every bump takes
SETTLEMENT_LOCK, so that is the revision the hold keeps, and the check
now fails unless it is the one whose work every frontend served. A read
still in flight when the wait's bound passes is cancelled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T03:27:12.834626Z c41618f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

RobertClarke and others added 2 commits October 5, 2026 23:06
…nd go ahead on current work when the cluster never goes quiet (#692)

Second review round. Every bump of the payout revision takes
SETTLEMENT_LOCK, so a found block still to land cannot move the revision
under the lock; the wait no longer counts unfinished candidates, which a
row left behind by an earlier fault would have kept above zero for the
whole bound. A quiet cluster, with no backend holding or waiting for
SETTLEMENT_LOCK, is now preferred rather than required: once the bound
passes the lock is taken on the work every frontend then serves, and the
check passes when the last reading before the lock was current and the
lock kept its revision. The revision read under the lock keeps its error
for the verdict, the evidence gives the wait from the injection's start,
and a phase that ends during the wait cancels its read.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 890bd5280e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qbit-prism-load/src/fault/mod.rs Resolved
…fail a hold whose work was not current there (#692)

Codex review. The wait's last reading is a snapshot taken before the
holder connects: a tip that reaches the frontends in between leaves the
payout revision as it was but not their work, and the hold then blocks
the rebuild. Once the lock is held nothing can publish, so the fault now
reads every frontend's /healthz once more before the hold starts, and
the check passes only when each one is ready and publishing work at the
revision read under the lock. A session still waiting for its first job
has nothing to submit and is not counted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RobertClarke
RobertClarke merged commit b0627b4 into 3.x.x Oct 6, 2026
34 checks passed
@RobertClarke
RobertClarke deleted the RobertClarke/692-settlement-lock-current-work branch October 6, 2026 03:43
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