Repository navigation
3.x.x: measure ORDER_LOCK holds by holder and landing-window share acks, guard settlement's hold over appends, and alert on slow landings (#602) - #615
Conversation
…ks, guard settlement's hold over appends, and alert on slow landings (#602) Step 1 of #602: measurement and guard, no behaviour change. Lock scope and settlement logic are unchanged. R3. qbit_prism_database_order_lock_hold_seconds{holder} records every ORDER_LOCK hold, from the grant of the lock to the end of its transaction, beside the existing wait histogram. Every ledger acquisition goes through Ledger::lock_order, which returns a guard the holder keeps until COMMIT or ROLLBACK. The guard starts from the instant the wait ended, so the append path reads no extra clock. Ten holders: append, candidate_insert, first_confirmation (the settlement that first confirmed its block), settlement (any other, including an abandon), reconcile, orphan, prepared (the refresh's window snapshot), cleanup, fatal_state and operator (policy and signing transitions, archive verify and restore). The schema cutover, whose transaction its caller commits, and archive's statement-scoped drain are not observed. The ladder runs from 1 ms to 10 s. A source scan keeps every other acquisition on the helper and every guard bound. R4. qbit_prism_share_ack_landing_window_seconds{result} holds the share_ack_seconds observations whose submission arrived within 30 s after a pool block acceptance this frontend observed: its own submitblock acceptance, or a peer's block on the active chain, seen before it is confirmed or already confirmed at the tip. A buried block first seen confirmed, as after a restart, opens none. It uses the same ladder, so steady state is a subtraction. The window's end sits in an atomic, so outside a window the Stratum path pays one atomic load, and the arrival instant it compares is the one the ack's elapsed time already uses. R7. Each window gets a verdict 30 s after it stops admitting submissions: its nearest-rank p99 exceeds a bound exactly when more than 1% of its acks did, counted exactly. qbit_prism_share_ack_slow_landing_windows {p99_above_seconds="2"|"10"} publishes the consecutive slow windows, -1 before the first verdict. PrismLandingAckP99Slow tickets at three windows in a row over 2 s; PrismLandingAckP99High warns at one over 10 s; PrismPoolResubmissionRejectRatioHigh warns when duplicate-share, unknown-job and stale-job rejections exceed 5% of the pool's decisions over five minutes. Thresholds are provisional. The deployment patch is regenerated. R6. A gated test holds a settlement open with a trigger that sleeps in its first-confirmation UPDATE and appends from the other frontend meanwhile. It is an expected failure: it passes while the appends wait for the settlement's COMMIT and fails with "#602 looks fixed" once they commit within #602's budget. Refs #602 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@cursor review |
…racker, let a window settle past the next acceptance, and simplify the hold guard (#602) Review follow-ups on the first commit: - A landing window no longer depends on the revision-work tracker's insert. That tracker's saturation, retired-height and capacity limits would have stopped every later window and frozen the slow-window gauge. LandingAcks now de-duplicates by block height itself, and the three acceptance hooks call it directly. - A later acceptance leaves the previous window settling, so its late (slow) acknowledgements count toward its own verdict instead of the next window's. - lock_order reads the clock after lock() returns. The shared lock helpers keep their original signatures. - Stratum and test acknowledgements share one recording path. - The settlement-hold probe matches only this database's sleeping qbit_pool_blocks UPDATE. - The source scan requires every explicit end of a hold to follow its COMMIT. - The R4 test no longer refreshes before the offering frontend's ack, since the refresh's reconciler would open the window on its own. - Docs: reconcile runs on every template build, and first_confirmation and settlement are counted per attempt. Refs #602 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@cursor review |
…a reorg's replacement block opens its own (#602) A reorg's replacement pool block at the same or a lower height is a new settlement under ORDER_LOCK, but height de-duplication gave it no landing window. LandingAcks now remembers the last 64 blocks that opened a window by hash (case-insensitive), so the reconciler seeing a block this frontend offered still opens nothing, and any other block opens its own. Refs #602 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1dbb6ff. Configure here.
Review ledger at
|
| Lane | Result |
|---|---|
/code-review medium (local, pre-PR) |
No bugs; one comment fixed. |
| Adversarial review (Claude) | No refutation. |
| Maintainability review (Claude) | No blockers; fixable items folded into the second commit. |
| Bugbot (high effort) | 1 medium finding on the second commit, fixed in 1dbb6fff. Clean before that. |
| Cross-provider adversarial lane | Not run: this change's review is limited to Claude models. |
| ID | Finding | Disposition |
|---|---|---|
| F1 | Landing windows depended on the revision-work tracker; saturating it would freeze the landing-window gauge. | Fixed: windows are de-duplicated independently of that tracker. |
| F2 | A later acceptance closed the previous window before its late acks counted. | Fixed: the previous window settles first. |
| F3 | lock_order read the clock before lock(), changing the shared lock helpers. |
Fixed: the clock is read after lock(). |
| F4 | Two share-ack recording paths. | Fixed: one path. |
| F5 | The source scan did not assert that every drop(order) follows COMMIT. |
Fixed, with mutant M9. |
| F6 | Bugbot: height-based de-duplication skipped a reorg's replacement pool block at the same or a lower height, which is a new settlement. | Fixed: de-duplicated by block hash over a bounded set of the last 64. The metrics-level test covers the same block twice (one window) and a different block at H and at H-1 (a window each). The mutant that restores the height key fails it. |
| R1 | A minimum sample count for the landing-window ticket. | Rejected by the review lane; kept as is. The ticket fires on three consecutive slow windows, and this can be revisited once production data exists. |
| R2 | Relabel the hold before COMMIT. | Rejected: holds are per attempt by design, and relabelling would merge retries. |
Measurements (posted on #602): at a 400k window with 2 frontends on a loaded host, first confirmation held ORDER_LOCK for 6–20 ms (38–42 ms at 2,600 recipients). Landing-window ack p99 was ≤ 50 ms, with no slow windows. The R6 expected-failure test shows the structural exposure: a 3 s settlement hold delays all concurrent appends by about 3 s.
Mutants: 8 code and 4 alert mutants, plus M8–M10 on the follow-ups, are all killed.
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]>
Refs #602. Step 1 of the plan: measurement and guard (R3, R4, R6, R7). No change to lock scope or settlement logic.
What changes
R3: ORDER_LOCK holds by holder.
qbit_prism_database_order_lock_hold_seconds{holder}sits beside the existing wait histogram. Every ledgerORDER_LOCKacquisition now goes throughLedger::lock_order. It returns a guard that the holder keeps until COMMIT or ROLLBACK, so a hold runs from the grant of the lock to the end of the transaction. The guard's clock starts at the instant the wait ended, so the append path reads no extra clock.appendcandidate_insertfirst_confirmationsettlementreconcileorphanpreparedcleanupfatal_stateoperatorThe schema cutover's hold is not observed, because its caller owns and commits the transaction. Archive's statement-scoped append drain is not observed either, because it holds nothing past its statement. The ladder runs from 1 ms to 10 s, so #602's 250 ms budget is a bucket edge. The label set is closed and its keys are reserved at declaration, so the first observation allocates nothing. A source scan (
every_order_lock_acquisition_records_its_hold) keeps every other acquisition on the helper and every guard bound until its transaction ends.R4: landing-window share acks.
qbit_prism_share_ack_landing_window_seconds{result}holds theshare_ack_secondsobservations whose submission arrived within 30 s after a pool block acceptance this frontend observed. An acceptance is its ownsubmitblockacceptance, or a peer frontend's block on the active chain, seen either before it is confirmed or already confirmed at the tip. The second case matters: the regtest measurement showed a peer's settlement usually finishes before this frontend's reconciler looks. A buried block first seen confirmed, as after a restart, opens no window. The family uses the same ladder, so steady state is a subtraction. The window's end sits in an atomic: outside a window the Stratum path pays one atomic load, and the arrival instant it compares against is the one the ack's elapsed time already uses. No extra clock read.R7: alerts. Each landing window gets a verdict 30 s after it stops admitting submissions. Its nearest-rank p99 is over a bound exactly when more than 1% of its acks took longer, and the process counts that exactly rather than reading buckets.
qbit_prism_share_ack_slow_landing_windows{p99_above_seconds="2"|"10"}publishes the number of consecutive slow windows, and -1 before the first verdict.PrismLandingAckP99SlowPrismLandingAckP99HighPrismPoolResubmissionRejectRatioHighAll three thresholds are provisional (#291). The promtool scenarios cover firing, pending, no verdict yet, reset, stale snapshot, low volume, other reasons and a frontend with a stale snapshot. The deployment patch is regenerated and the deployment test checks the new rules' severity, dwell and no-data states.
R6: guard.
appends_commit_within_budget_while_a_settlement_is_heldholds a real settlement open: a trigger sleeps 3 s inside the offering frontend's first-confirmationUPDATE. Meanwhile the other frontend runs 8 appends. It is an expected failure, following the #582 / #598 pattern. It passes while the appends wait for the settlement's COMMIT, and it checks that they were delayed by the held settlement, not by something else. Once they commit within #602's budget (no ack over 2 s, p99 at most 500 ms), it fails with "#602 looks fixed".Measurement (#602 item e)
Measured on regtest and on the fake node with a 400k window, 2 release frontends, 100 sessions at 100 shares/s and 3 own blocks per run, on a loaded shared host (4 pinned cores). Full tables are in the #602 comment.
ORDER_LOCKfor 6-20 ms with 5-130 recipients and 38-42 ms with 2,600. It grows with accounts, not with the window, and stays well under R2's 250 ms.Tests
tests/b602_order_lock_hold.rs, listed intest/prism-gated-tests.txt:a_landing_records_each_order_lock_hold_under_its_holder(R3)acknowledgements_after_an_acceptance_are_read_in_the_landing_window(R4, over a real Stratum socket)appends_commit_within_budget_while_a_settlement_is_held(R6)metrics::landing_acks), with a paused clock.Mutants, each run against the test that should catch it:
a_landing_records…: "is not a first_confirmation hold"a_landing_records…: "held ORDER_LOCK 0 s, outside [0.3, …]"first_confirmationrelabela_landing_records…acknowledgements_after…: "…after its own acceptance is missing from the landing window"acknowledgements_after…: "…after a peer's landing is missing from the landing window"acknowledgements_after…: "an acknowledgement with no acceptance was read as a landing window's"ORDER_LOCK(a stand-in for the step-2 fix)appends_commit…: "#602 looks fixed: every append committed within 2s (slowest 45.8ms…)"landing_acksunit test🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.