Skip to content

Review finding: a failed commit in a background top-up aborts the process #319

Closed

Description

@kiwidream

Summary

A failed commit in a background top-up aborts the process from the scheduler thread.

Severity: low. Found in the 2026-11-04 review of the v1.0.1 change set (all 1.x.x merges since v1.0.0 plus the open PRs that target it), against 1.x.x 21fee6ee8e; area: #144.

Observed

Confidence: confirmed from code (the exception propagates to std::terminate); the trigger needs a COMMIT failure.

  • Location: src/wallet/scriptpubkeyman.cpp:1305-1313 (the self-committing top-up throws std::runtime_error after a failed TxnCommit, even when TxnAbort and the in-memory rollback succeeded); callers RunScheduledPendingInitialKeyPoolTopUp and RunScheduledP2MRKeyPoolRefill (src/wallet/wallet.cpp:378-487) do not catch; CScheduler::serviceQueue rethrows and util::TraceThread rethrows, so the process calls std::terminate (src/scheduler.cpp, src/util/thread.cpp:16-28), at 21fee6e.
  • Scenario: the disk fills, or the database hits an I/O error at COMMIT, during a deferred or low-watermark refill. That can happen up to about 60 s of SLH-DSA derivation after wallet creation or unlock. qbitd or qbit-qt then aborts. Since wallet: publish descriptor top-ups after commit #144 the memory state, the publication and the transaction are already rolled back when the exception is thrown. The throw is therefore not needed for consistency in the aborted == true case, and MaybeTopUpInternalP2MRKeyPool already catches the same exception for the inline path.
  • Evidence: code read, not run.

Impact

This is a crash on a recoverable storage error in background work the user did not start. It is pre-existing: v1.0.0 also threw on commit failure, and Bitcoin Core does so on its blockConnected -> MarkUnusedAddresses path. It is reported because the deferred and low-watermark refills are qbit-specific scheduler paths that run for much longer.

Suggested fix

When the abort after a failed commit succeeded, return util::Error instead of throwing, which the background steps already handle as FAILED and "paused". Keep the throw only when TxnAbort fails. Alternatively, catch std::exception in the two RunScheduled* functions, log it, and clear the scheduled flags.

Activity

  1. added
    bug
    on Nov 4, 2026
  2. added 2 commits that reference this issue on Nov 4, 2026
    219490f
    dd86425
  3. kiwidream commented on Nov 5, 2026

    @kiwidream
    MemberAuthor

    Fixed on 1.x.x by #299 (merged as dd86425), which reports a rolled-back top-up commit failure as an error that pauses the background refill, instead of throwing from the scheduler and aborting the process. main gets the fix when 1.x.x is integrated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions