Indexes: Harden the flush-error notification invariant #35731

pull arejula27 wants to merge 4 commits into bitcoin:master from arejula27:flush-notify-invariant changing 5 files +121 −10
  1. arejula27 commented at 5:35 PM on July 15, 2026: none

    This is a follow-up to #35714 as it has the two commits of that PR, do not merge or review before that PR

    #35714 makes FlushStateToDisk() return state.Error(...) when FlushChainstateBlockFile() fails, relying on the comment // FlushChainstateBlockFile() already emitted the flush-error notification.

    That invariant holds today, but it is not guaranteed by construction: it depends on every success = false branch inside FlushBlockFile/FlushUndoFile emitting the notification on its own. A future flush source (a new file type, a new error branch) that sets success = false without notifying would make FlushStateToDisk() return an error without AbortNode().

    This PR makes sure that whenever a flush reports failure, the flush-error notification has been emitted:

    • test: cover FlushBlockFile flush-error notifications: lower-level BlockManager tests (as suggested in the #35714 review) that inject a failure on the block file and on the undo file separately and assert each failure emits flushError.
    • blockstorage: encapsulate flush+notify in FlushFile: a single FlushFile() helper couples the flush and the notification; FlushBlockFile/FlushUndoFile delegate to it. Behaviour is unchanged.
  2. test: characterize writes after flush failure 0f04fbee2f
  3. validation: stop writes after flush failure
    When a block-file or undo-file flush fails, shutdown is requested, but `FlushStateToDisk()` still writes block-index metadata and coins data, then advances `m_last_flushed_block`.
    Return the error before those writes, keeping `m_last_flushed_block` at the last successful flush.
    e1a337ee96
  4. test: cover FlushBlockFile flush-error notifications 42ea4bcccb
  5. blockstorage: encapsulate flush+notify in FlushFile a4c7bf0fbf
  6. DrahtBot added the label UTXO Db and Indexes on Jul 15, 2026
  7. DrahtBot commented at 5:35 PM on July 15, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35731.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35307 (blockstorage: keep snapshot base in normal blockfile range by shuv-amp)
    • #35003 (validation: improve block data I/O error handling in P2P paths by furszy)
    • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)
    • #29700 (kernel, refactor: return error status on all fatal errors by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  8. DrahtBot added the label CI failed on Jul 20, 2026
  9. DrahtBot commented at 11:17 AM on July 20, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/29437114552/job/88325958979</sub> <sub>LLM reason (✨ experimental): CI failed because IWYU reported required header/include fixes (it modified src/node/blockstorage.h and exited non-zero).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-21 19:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me