Repository navigation
3.x.x: make the live_regtest port-reservation, failover share-count and weighted-recipients RPC waits deterministic under load (#533) - #563
Merged
Conversation
…nd weighted-recipients RPC waits deterministic under load (#533) fixture_ports_stay_reserved_until_their_child_starts proved a release by binding the released port again. A released port goes back to the host, and a concurrent test's free_port() child or reservation can bind it first, so the bind failed with "Address already in use". The test now checks the reservation's own sockets: exactly the released ports leave the held set, their listening sockets are closed (by socket inode, on Linux), the others stay open and still refuse a bind, and dropping the reservations closes every socket. real_two_server_mining_failover_audit_and_reorg read the accepted share count, then the two API counts, right after stopping the miners. A share a server read before its miner was killed can still commit in between. The count and the credited-header count now come from one snapshot, and each API count is compared with a count that is the same before and after the API reads, retried for up to 30 s. A wrong API count still fails. real_weighted_recipients_pay_exact_pplns_outputs_through_fanout_spend's difficulty ramp mines 250 blocks per generatetoaddress; at a host load average of 50 one batch outran the fixture client's 45 s timeout. That call and the file's wallet calls (the payees' many-input sendall is the other heavy one) now carry a 600 s per-request deadline. Neither is idempotent, so neither is retried. Test-only. Closes #533. Refs #562. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
Review ledger (#533)This PR changes tests only, so under the current policy it got a proportionate check rather than a full deep review: one Review findings
The review also checked the following and found them sound:
Bots: Separate mode noted in the PR body
CIAll required checks green on the PR head. |
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the three load-sensitive
live_regtestcases from #533 deterministic. Test-only: no production code changes, and no assertion is removed or loosened.fixture_ports_stay_reserved_until_their_child_starts: "Address already in use"Cause. The test proved that a release works by binding the released ports again, and that dropping the reservations works by binding the rest. A released port goes back to the host at once. In the full binary, the concurrent live tests start children on ports from
free_port()and take their own reservations, and any of them can bind a released port first. The test's own bind then failed withAddress already in use (os error 98).Fix. The release is now checked on the reservation's own sockets, not on the host's port table:
release, the held set is exactly the unreleased ports;real_two_server_mining_failover_audit_and_reorg: API share-count read raceCause. After
quiesce()(miners killed, candidate outbox drained), the test read the accepted-share count, then the credited-header count, then each server's/audit/latest. A submission a server had read before its miner was killed can still commit between those reads. The API then reports one more share than the count read before it, or the header count differs by one from the share count.Fix. Both counts come from one statement, so they share a snapshot, and
count == uniquestays exact. Each API count must equal a share count that is the same before and after the two API reads. If a late commit lands in between, the check is repeated for up to 30 s. A wrong API count still fails, now with both counts in the message.real_weighted_recipients_pay_exact_pplns_outputs_through_fanout_spend:operation timed outCause. The difficulty ramp mines in 250-block
generatetoaddressbatches through the fixture client, whose timeout is 45 s. At a host load average of 50–60, the node connected about 5 blocks a second, and one batch outran the timeout. The error waserror sending request for url (…/), raised while the servers' logs showed the ramp's heights still advancing. The payees' many-inputsendallis the file's other heavy call.Fix.
generatetoaddress(the newgeneratehelper) and the file'swallet_rpccarry their own 600 s per-request deadline,HEAVY_RPC_TIMEOUT. Neither call is idempotent, so neither is retried. Fixture reads keep the 45 s client timeout.Evidence
Every run pins the test binary, its qbitd and servers, and the private PostgreSQL 16 (fsync on) to the same two cores.
Injected faults. Each fault is identical in the before and after builds:
releaseAddress already in use (os error 98)API does not expose cluster share countgeneratetoaddressbatch)sendallMutants. Each mutant was run against the fixed tests:
releasedrops the entry but leaks the socketreleaseis a no-opaccepted_share_countis one too highAPI does not expose cluster share count 16 (then 16): … 17after the 30 s boundStress. Each session was bounded, with 2 CPU burners on the two cores:
A separate mode, tracked in #562 and not changed here. Under the burners, the failover test sometimes fails earlier, at
timed out waiting for surviving server mining. That is the 20 s wait for server 1 to gain three shares after server 0 is killed, and it comes before the code this PR touches. In regtest every share meets the block target, so server 0 is almost always mid-landing when it is killed. In each failure, server 1 then logged nothing and answered no submission for the whole window.CI runtime
No measurable change. The loop in the failover test normally finishes in one pass. The deadlines only lengthen how long a heavy call may take, and add no waits.
Checks
cargo clippy --locked -p qbit-prism-server --test live_regtest -- -D warnings: clean.cargo fmt --all --check: clean./code-reviewmedium: no findings.test/prism-gated-tests.txtis unchanged, because no test id changed.Closes #533
Refs #562
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.