Skip to content

3.x.x: bound the failover test's share and subscribe waits by the server's own answer bounds (#562) - #572

Merged
djh58 merged 1 commit into
3.x.xfrom
djh58/prism-b-flakes-562
Sep 29, 2026
Merged

djh58 merged 1 commit into
3.x.xfrom
djh58/prism-b-flakes-562

Conversation

@djh58

@djh58 djh58 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Makes live_regtest::real_two_server_mining_failover_audit_and_reorg wait for its shares by the server's own answer bound instead of a fixed 20 s. Test-only: the counts compared and the shares required are unchanged.

Cause

After server 0 is killed, the test waits a fixed 20 s for three newly credited shares on server 1. It waits the same way on the restarted server 0. Every regtest share is also a block. A block proof on work whose payout revision a landing superseded is captured (#478) and takes the block-only path with its share deferred. Its Stratum answer waits for that server's own landing of the block, up to block_only_ack_timeout: max(share_commit_timeout, 60 s), which is 60 s here. The miner answers each submission in turn, so a slow landing holds everything behind it. Under host-wide load (load average 30–50), landings took seconds each, and three credited shares outlasted 20 s. That was 4 of 63 runs, all with timed out waiting for surviving server mining.

What it is not: the killed peer's own leftovers. The runs below used a one-shot trigger to hold server 0's offered → landed transition, then killed server 0 mid-landing (its row stays offered under its 120 s claim). In all 3 runs the survivor still credited three shares within 1.2 s, and its captured proofs answered in about 200 ms.

Fix

  • Both share waits now allow 20 + 3 × block_only_ack_seconds (200 s): each of the three shares may use its whole answer bound. A healthy run still finishes in about 1 s, because the wait returns as soon as the count is reached.
  • subscription()'s read deadline goes from 5 s to 35 s, because the server bounds session allocation by initial_job_timeout_seconds (30 s by default).

Evidence

All runs pin the test binary, qbitd, both servers and the private PostgreSQL 16 (fsync on) to the same two cores.

Condition Before After
Injected slow landing: live-1's first offer_reserved transition after the kill held 25 s by a trigger 6 of 6 fail, timed out waiting for surviving server mining the survivor wait passes 9 of 9 (15–61 s)
Plain, 3 consecutive runs — 3 of 3 pass (6–7 s; one 125 s run waited out a landing claim in quiesce)
2 CPU burners on the same two cores, bounded session — 18 of 18 pass
Mutant: the survivor's miner is also stopped at the kill — fails at the new bound (205 s) with timed out waiting for surviving server mining

Caveat on the injected runs after the fix. Some later failed further on, at a different step. The injection sleeps inside a live transaction, and server 0's restart queues behind the locks that transaction still holds, so its startup statements and the test's own reads hit lock_timeout. That is an artifact of holding a 25 s transaction, not the condition this PR addresses.

Delay chosen. An 8 s landing delay did not fail the old test: the survivor needed 16.6 s against 20 s. A delay inside the landing's own transaction also trades waits for 5 s lock timeouts. 25 s at offer_reserved is the smallest placement that failed the old test every time.

Follow-up

Whether a captured block proof's answer should wait for its landing at all is a product question; a follow-up issue has been drafted for the #478 owner. This PR only makes the test honour the current bound.

CI runtime

None in a healthy run: each wait returns as soon as its condition holds.

Checks

  • cargo clippy --locked -p qbit-prism-server --test live_regtest -- -D warnings: clean.
  • cargo fmt --all --check: clean.
  • test/prism-gated-tests.txt is unchanged, because no test id changed.

Closes #562

🤖 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.

…ver's own answer bounds (#562)

real_two_server_mining_failover_audit_and_reorg waited a fixed 20 s for
three newly credited shares on the surviving server after the other is
killed, and again on the restarted server. Every regtest share is also a
block. A proof on work whose payout revision a landing superseded is
captured (#478), and its answer waits for that server's own landing of
the block, up to block_only_ack_timeout (max(share_commit_timeout, 60 s),
60 s here). Under host load a landing takes seconds, so three credited
shares outlasted 20 s. Both waits now allow 20 s plus three full answer
bounds. The shares required and the counts compared are unchanged.

The fixture's subscribe read deadline was a fixed 5 s, but the server
bounds session allocation by initial_job_timeout_seconds (30 s by
default); it now waits 35 s.

A killed peer's own claims do not stall the survivor: with server 0 killed
while its block was offered (its row left claimed for 120 s), the survivor
credited three shares within 1.2 s. Its captured proofs answered in about
200 ms.

Test-only. Closes #562.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@djh58
djh58 requested a review from kiwidream September 29, 2026 13:42
@djh58

djh58 commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

Review ledger (#562)

This PR changes tests only, so under the current policy it got a proportionate check rather than a full deep review: one /code-review medium pass, the deterministic slow-landing injection before and after, a mutant, and bounded stress runs (all in the PR body).

Review findings

# Finding Disposition
— /code-review medium: no findings. —
1 Review note, not a defect: the new comment assumes a captured block proof's credit is an accepted qbit_share_ledger row that count() sees. Verified. The block-only wait ends Accepted only once the deferred share's row exists in qbit_share_ledger, which is the row count() counts.

The review also checked the following and found them sound:

  • block_only_ack_timeout is max(share_commit_timeout, 60 s), which is 60 s with the fixture's defaults.
  • The fixture does not override initial_job_timeout_seconds (30 s), so the 35 s subscribe deadline covers the server's own bound.
  • The until bounds are in seconds.
  • Nothing ends the test before the new bounds.

Follow-up

The product question, whether a captured proof's acknowledgement should wait for its landing at all, is drafted as a separate issue for the #478 owner.

CI

All required checks green on the PR head (0c8b9b1, rebased cleanly onto 3.x.x after #563 merged; hunks unchanged, clippy and fmt re-run clean). [code]smith skipped; no other review comments.

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