Skip to content

backport: bitcoin#34857 - #8216

Merged
PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix/wallet-reindex-flake
Nov 22, 2026
Merged

PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix/wallet-reindex-flake

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

wallet_reindex.py --descriptors failed all three attempts of linux64-test / Test source on a runner with very slow disk I/O (job):

File "test/functional/wallet_reindex.py", line 75, in birthtime_test
    with node.assert_debug_log(expected_msgs=["loadblk thread exit"]):
AssertionError: [node 0] Expected messages "['loadblk thread exit']" does not partially match log

assert_debug_log starts its deadline (2 s × timeout factor, so 8 s in CI) when the with block is entered. The block then contains a full restart_node, so the stop, the restart and the whole reindex all run inside those 8 s. In the failing run the stop alone took about 30 s, loading the block index took about 4 s and reconnecting 160 blocks took about 17 s. Nothing was stuck. By the time restart_node returned, the deadline had long expired, so assert_debug_log read the log only once.

restart_node returns as soon as getmempoolinfo reports loaded. In Dash that flag is set partway through the loadblk thread: after it the thread still sends tip notifications, writes the evodb repair marker with a forced chainstate flush, and fills the masternode coin cache before loadblk thread exit is logged. In the failing log the node was inside that final flush when the single read happened. So the test passes only when the entire stop/restart/reindex fits in the deadline or the remaining work happens to finish before the read.

Bitcoin Core hit the same race with its initload thread and fixed it in bitcoin#34857 by removing the wait. restart_node already waits for the import to finish, and the wallet RPCs that follow call BlockUntilSyncedToCurrentChain(), so the extra syncwithvalidationinterfacequeue() can go too.

What was done?

Backport of bitcoin#34857 (test: Remove confusing assert_debug_log in wallet_reindex.py).

Dash adaptations:

  • The removed wait names Dash's loadblk thread instead of initload. The surrounding context differs because Dash still runs this test with --legacy-wallet.
  • -reindex=1 is kept on the restart. Upstream's change also drops it, which leaves the test restarting without reindexing even though it still logs "Reindex ...". Keeping it preserves what the test is named for. wallet, test: remove unnecessary node restart from wallet_reindex bitcoin/bitcoin#34879 (open upstream) proposes removing this restart entirely.

How Has This Been Tested?

Ran the test directly in a loop on a heavily loaded Linux x86_64 host (RelWithDebInfo build of this branch), 10 at a time, datadirs on disk:

--timeout-factor=1 --timeout-factor=4
develop 14 of 40 failed with the CI assertion 0 of 40 failed
this PR 0 of 80 failed 0 of 40 failed

Both 40-run batches on this branch used upstream's exact pick (no -reindex); the 80 runs used the final version, which keeps it. A --nocleanup run confirms the restart reindexes (Reindexing block file in the node log). test_runner.py with 8 × wallet_reindex.py --descriptors and 8 × wallet_reindex.py --legacy-wallet passes. test/lint/lint-python.py reports no new findings (its only output is three mypy errors that develop shows too).

feature_reindex.py (kill_after_reindex) uses the same assert_debug_log around start_node, but there waiting for the thread exit is the point, and its 10 s × timeout-factor budget covers only the start and reindex, not a stop. It has not been seen failing, so it is left unchanged.

Breaking Changes

None. Test-only.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…t_reindex.py

fa30951 test: Remove confusing assert_debug_log in wallet_reindex.py (MarcoFalke)

Pull request description:

  The `wallet_reindex.py` test has many issues:

  * It uses a `assert_debug_log` to ensure the reindex happened via `initload thread exit`. However, no other test uses this pattern, because `restart_node` already achieves the same internally (via `getmempoolinfo.loaded`).
  * The `assert_debug_log` may intermittently fail, because the `initload thread exit` log may happen at any time after the inner thread function (lambda) is fully done.
  * The test uses an `node.syncwithvalidationinterfacequeue()` without any explanation. No other test uses this pattern, because all wallet RPCs, in particular the next one (`gettransaction`) call it internally (via `BlockUntilSyncedToCurrentChain`).

  Fix all issues by removing all confusing, useless, and brittle calls.

  Example failure: https://github.com/bitcoin/bitcoin/actions/runs/22671604602/job/65716917459?pr=34419#step:11:22339

  ```
  ...
   node0 2026-03-04T13:55:23.784715Z (mocktime: 2026-03-04T22:15:17Z) [scheduler] [validationinterface.cpp:185] [operator()] [validation] UpdatedBlockTip: new block hash=24b5cc4c1352bc8841ecbe67a43827acd1adc609bd26b2691e80e89b97eff135 fork block hash=24a4dc8be9c157ac31913397d8bb1653900e12b55539c234039559fdeb6dd2fb (in IBD=true)
   node0 2026-03-04T13:55:23.784851Z (mocktime: 2026-03-04T22:15:17Z) [initload] [util/thread.cpp:22] [TraceThread] initload thread exit
   test  2026-03-04T13:55:23.813824Z TestFramework (ERROR): Unexpected exception:
                                     Traceback (most recent call last):
                                       File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_framework.py", line 142, in main
                                         self.run_test()
                                       File "/home/admin/actions-runner/_work/_temp/build/test/functional/wallet_reindex.py", line 90, in run_test
                                         self.birthtime_test(node, miner_wallet)
                                       File "/home/admin/actions-runner/_work/_temp/build/test/functional/wallet_reindex.py", line 64, in birthtime_test
                                         with node.assert_debug_log(expected_msgs=["initload thread exit"]):
                                       File "/usr/lib/python3.12/contextlib.py", line 144, in __exit__
                                         next(self.gen)
                                       File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_node.py", line 607, in assert_debug_log
                                         self._raise_assertion_error(f'Expected message(s) {remaining_expected!s} '
                                       File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_node.py", line 241, in _raise_assertion_error
                                         raise AssertionError(self._node_msg(msg))
                                     AssertionError: [node 0] Expected message(s) ['initload thread exit'] not found in log:
  ```

  Diff to reproduce failure:

  ```diff
  diff --git a/src/util/thread.cpp b/src/util/thread.cpp
  index 0fde73c..de4c05e752 100644
  --- a/src/util/thread.cpp
  +++ b/src/util/thread.cpp
  @@ -8,2 +8,3 @@
   #include <util/log.h>
  +#include <util/time.h>
   #include <util/threadnames.h>
  @@ -21,2 +22,3 @@ void util::TraceThread(std::string_view thread_name, std::function<void()> threa
           thread_func();
  +    UninterruptibleSleep(999ms);
           LogInfo("%s thread exit", thread_name);
  diff --git a/test/functional/wallet_reindex.py b/test/functional/wallet_reindex.py
  index 71ab69e..649df4301a 100755
  --- a/test/functional/wallet_reindex.py
  +++ b/test/functional/wallet_reindex.py
  @@ -62,2 +62,3 @@ class WalletReindexTest(BitcoinTestFramework):

  +        import time; time.sleep(1) # Wait for previous initload thread to exit fully
           # Reindex and wait for it to finish
  ```

  Before on master: Test fails
  After on this pull: Test passes

ACKs for top commit:
  rkrux:
    ACK fa30951 if this PR needs to be backported.

Tree-SHA512: 1e6599511e09b5b9ac4aed96a6b1b8239d5dc63b164fc0c163b6f9f5bc72c1c61f72ad8256a01875208d825af46d057c4d9de61758002f256388ddb324006bb5
Dash adaptations: keep `-reindex=1` on the restart. Upstream dropped it in
this change, which leaves the test restarting without reindexing; the
removed wait names Dash's `loadblk` thread instead of `initload`.

(cherry picked from commit 16613c9)
@PastaPastaPasta PastaPastaPasta added this to the 24.1 milestone Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The wallet reindex test now logs the reindex step instead of asserting a debug-log message and synchronizing the validation-interface queue. It still restarts the node with -reindex=1 and the current mock time. The later transaction-confirmation and wallet-birthtime checks remain.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • dashpay/dash#7946: This PR also changes the loadblk log-wait behavior in wallet_reindex.py.

Suggested reviewers: dcg-claude

Merge Risk: Minimal · up to 1651a

This test-only change makes the wallet reindex functional test less likely to fail under slow I/O. It has no production impact and is low risk to merge.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title "backport: bitcoin#34857" names the upstream change being backported, but it does not describe the change itself. It gives no hint that the change removes an assert_debug_log wait in wallet_… Rewrite the title to name the primary change. For example: "test: remove brittle assert_debug_log wait in wallet_reindex.py". This keeps the upstream reference (bitcoin#34857) in the description or the title suffix.
Passed Passed checks: 3 passed

Check name Status Explanation
Description check Passed The description explains the CI failure in wallet_reindex.py, where assert_debug_log's deadline covers a full restart_node. It states the removal of the loadblk-thread wait and the syncwithvalidationi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the CI failure in wallet_reindex.py, where assert_debug_log's deadline covers a full restart_node. It states the removal of the loadblk-thread wait and the syncwithvalidationinterfacequeue() call, the retained -reindex=1 flag, and the test results. It is directly related to the changeset.

Full details: Title check

Explanation

The title "backport: bitcoin#34857" names the upstream change being backported, but it does not describe the change itself. It gives no hint that the change removes an assert_debug_log wait in wallet_reindex.py. A reader scanning history cannot tell the primary change from the title alone. The title is vague and generic, so the check is inconclusive.

Resolution

Rewrite the title to name the primary change. For example: "test: remove brittle assert_debug_log wait in wallet_reindex.py". This keeps the upstream reference (bitcoin#34857) in the description or the title suffix.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7fbb2806-3637-4d2d-ae47-336392ae21bc
Commits

Reviewing files that changed from the base of the PR and between b0d17d4 and 1651ac0.

Files selected for processing: 1

  • test/functional/wallet_reindex.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@thepastaclaw

thepastaclaw commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 1651ac0) · triage: low

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

The backport is a focused test-only change that removes the racy debug-log wait and redundant validation-interface synchronization while retaining Dash’s -reindex=1 coverage. The changed test logic is supported by restart_node’s import-completion wait and the following wallet RPC synchronization; build, lint, cppcheck, and formatting checks pass, with the functional test job still in progress and no reported failure.

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: backport-reviewer); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff removes two synchronization checks from one functional test while preserving the reindex restart, with no production code changes.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 100% left, weekly 47% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — backport-reviewer (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort medium); agent phase2-reviewer

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 21, 2026

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Approved

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.

3 participants