#35731 Indexes: Harden the flush-error notification invariant

full analysis

https://github.com/bitcoin/bitcoin/pull/35731 · arejula27 · +121/-10 in 5 files, 4 commits · labels: UTXO Db and Indexes, CI failed · draft

Goal

  • Ensure all block and undo file flush failures reliably trigger flush-error notifications by construction
  • Add dedicated unit tests to verify error notifications fire during simulated I/O failures

This PR couples block and undo file flushing with error notifications inside a new BlockManager::FlushFile helper so that any flush failure consistently emits a flush-error notification. It also introduces unit tests that inject I/O failures to verify notifications fire separately for block files and undo files.

Problem: FlushStateToDisk relies on FlushChainstateBlockFile emitting a flush-error notification before returning failure. While this invariant currently holds, it is not enforced by construction across all flush branches and lacks dedicated unit test coverage.

Category: Validation (#40 of 48)

P3 · test coverage

  • P3 because this is defensive internal hardening that leaves current behavior unchanged
  • Adds targeted test coverage to prevent future regressions in fatal storage error handling

P3 because this is defensive internal hardening that leaves behavior unchanged while adding valuable unit test coverage for fatal block storage error paths. As the author notes, 'That invariant holds today, but it is not guaranteed by construction', making this an internal refactor to prevent future regressions.

Membership: Modifies BlockManager flush methods in src/node/blockstorage.cpp and validation flush error handling.

Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 1

Reviewability: Paused: Review #35714 first

  • Review #35714 first
  • CI is currently failing

The author explicitly requested not to review or merge before #35714, which this PR includes commits from. CI is also failing and the author has been silent for 63 days.

Author status: silent since 2026-07-15

Agreement: Crickets

  • No reviews or concept comments yet
  • Opened as a follow-up to PR 35714 with no community feedback so far

No reviews or concept comments yet

The pull request was opened in draft as a follow-up to #35714 and has received no feedback.

Review verdicts (DrahtBot): 0

Dependencies

Depends on: #35714

Files

103 lines under test/bench/ci.

  • src/test/blockmanager_tests.cpp +79/-0
  • src/test/chainstate_write_tests.cpp +24/-0
  • src/node/blockstorage.cpp +11/-7
  • src/node/blockstorage.h +5/-0
  • src/validation.cpp +2/-3

Card

This PR hardens BlockManager flush handling by encapsulating the flush and notification inside FlushFile so every failure path emits a flush-error notification, backed by targeted failure-injection tests. It prevents potential regressions in fatal node shutdown handling when block or undo file writes fail. The PR is an unreviewed draft follow-up to #35714 that the author requested not be reviewed until the base PR lands.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:54, confidence high, input hash 4c8fc6ce4efebbd5