Repository navigation
test: fix intermittent baseindex_tests failure from undrained reorg notifications - #8177
PastaPastaPasta wants to merge 1 commit into
Conversation
…ex starts LowerLastFlushedBlock() reorgs the chain (invalidate, flush, reconnect) and returned with up to ten of the reorg's validation notifications still queued: InvalidateBlock() and ActivateBestChain() only drain the queue once it holds more than ten callbacks. The notifications are delivered to whatever is registered when the scheduler gets to them, so with a loaded scheduler thread they could reach the index that the test starts next. That index is already synced to the tip, so a stale BlockConnected for a block it has indexed looks like a reorg: it rewinds to the block's parent and moves its committed locator down. In restart_after_rewind_reindexes_erased_blocks, that broke the check that the restarted index's committed tip is still 100, and the one after the rewind to 97. Wait for the notifications in the helper, while no index is registered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughAfter reconnecting blocks, Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Merge Risk:
|
|
✅ Final review complete — no blockers (commit d7a8078) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The test-only change correctly places a FIFO validation-interface queue barrier after LowerLastFlushedBlock() completes its reorg and before either caller starts another index. This prevents stale reorg notifications from being delivered to a newly registered, already-synced index; no in-scope correctness issues were found. Lint, ClangFormat, Cppcheck, and completed build checks pass; remaining build/test checks were still pending in the supplied CI snapshot, with no failed code check attributable to this change.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, self-contained test-helper change that drains queued validation notifications without altering production behavior or critical code paths. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 50% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— dash-core-commit-history (completed, effort medium); agentphase2-reviewer
Issue being fixed or feature implemented
baseindex_tests/restart_after_rewind_reindexes_erased_blocks(added in #8042) fails intermittently on a loaded machine: the restarted index's committed tip isn't 100, and after the rewind it isn't 97. Running the test 40 at a time, niced, it failed 14 times in 8000 runs (one as a segfault).The cause is the test helper
LowerLastFlushedBlock(). It reorgs the chain (invalidate, flush, reconnect) and returns with up to ten of the reorg's validation notifications still queued, becauseInvalidateBlock()andActivateBestChain()only drain the queue once it holds more than ten callbacks. Notifications go to whatever is registered when the scheduler gets to them, so a slow scheduler thread hands them to the next index the test starts. That index is already synced to the tip, so a staleBlockConnectedfor a block it has indexed looks like a reorg: it rewinds to that block's parent and moves its committed locator down (to 97 or 99 in the failures).Upstream has no equivalent fix to backport: this test and helper are Dash-only. bitcoin#36447 drains pending events before indexes are stopped, which this test already does; the stale events here are created after the first index has stopped.
What was done?
LowerLastFlushedBlock()now callsSyncWithValidationInterfaceQueue()before returning, so the reorg's notifications are delivered while no index is registered.restart_rewinds_blocks_synced_above_flushuses the same helper and gets the same protection.How Has This Been Tested?
BlockConnected, registered beforeLowerLastFlushedBlock(), plus a drain right after the second index'sStart(). Without the fix the test failed 30/30 with the same two checks; with it, 0/30.baseindex_tests,blockfilter_index_tests,txindex_testsandcoinstatsindex_testspass 10/10 each (Linux x86_64, CMake build against depends).Breaking Changes
None; test-only.
Checklist:
🤖 Generated with Claude Code