mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 12:20:38 +00:00
Indexes: Harden the flush-error notification invariant #35731
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35731
Loading…
Reference in a new issue
No description provided.
Delete branch "flush-notify-invariant"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
FlushStateToDisk()returnsstate.Error(...)whenFlushChainstateBlockFile()fails, relying on the invariant that the flush-error notification has already been emitted (so the node is aborted). Today that invariant holds only because everysuccess = falsebranch inFlushBlockFile/FlushUndoFilehappens to callflushError()itself. A future flush source, or a new error branch, that fails without notifying would makeFlushStateToDisk()report an error withoutAbortNode()being triggered.This PR makes that invariant hold by construction: whenever a flush reports failure, the flush-error notification has been emitted.
BlockManagerunit tests that inject a failure on the block file and on the undo file separately, and assert that each failure emitsflushError.FlushFile()helper performs the flush and emits the notification on failure;FlushBlockFileandFlushUndoFiledelegate to it. No behaviour change.Follow-up to #35714. Possible further work on flush error handling is listed in https://github.com/bitcoin/bitcoin/pull/35714#pullrequestreview-5697890316 (pruned-file deletion after a failed flush is handled in #36735).
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
MSG_BLOCKby stripping witnesses in place by l0rinc)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.
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/29437114552/job/88325958979LLM reason (✨ experimental): CI failed because IWYU reported required header/include fixes (it modified
src/node/blockstorage.hand exited non-zero).Hints
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.
Earlier concerns remain unresolved; see the full report for their current assessments.
🔴 Major · Keep chain and coin state coherent after a failed flush
validation.cpp:3134-3159: ConnectTip (and likewise DisconnectTip) still flushes coin changes into CoinsTip, then returns on a failed IF_NEEDED flush before SetTip, so the coins tip can end up ahead of m_chain. After the rebase this is base code from merged #35714, and this PR does not touch validation.cpp. Impact on kernel applications is still unconfirmed.
Location:
src/validation.cpp:3134(head).🔵 Suggestion · Flush notification tests discard the error message
A block/undo message mix-up in the refactored helper calls would still pass both new unit tests.
Location:
src/test/blockmanager_tests.cpp:47(head).🔵 Suggestion · FlushFile constructs error messages on successful flushes
Both callers now construct bilingual error strings and invoke any configured translator before flushing, even when the flush succeeds.
Location:
src/node/blockstorage.cpp:750(head).🔵 Suggestion · Undo failure test rebuilds the undo path through std::string
The undo test bypasses fs::path's string-conversion guards and duplicates the block/undo naming convention, although its existing friend accessor can obtain the actual undo path.
Location:
src/test/blockmanager_tests.cpp:421(head).Review coverage was incomplete.
Reviewed:
2d7830b0928c· Full review report · Previous reportspermalink
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased onto current master and converting from draft to open.
@ryanofsky's follow-up list on #35714 also flagged more to do here, I'll do that in the next few days.
Concept ACK
2d7830b092on new test coverage and bundling Flush/flushError together.For the follow-ups in https://github.com/bitcoin/bitcoin/pull/35714#pullrequestreview-5697890316, note that #36735 is taking item 7 (deleting pruned files after a failed flush), so it might make sense to coordinate there. For items changing how errors are reported (like turning warnings into failures), I could be best to start with item 4, documenting how callers should use the
FlushStateToDisk()return value, so later changes can follow a consistent rule instead of being made one at a time.Would also be good to update description now that PR https://github.com/bitcoin/bitcoin/pull/35714 is merged, and maybe simplify a little so this can be understood without needing to understand the #35714 history
Thanks for the review @ryanofsky . I've updated the PR description so it no longer depends on #35714's history. I'll start with documenting how callers should use the
FlushStateToDisk()return value (item 4) and leave item 7 to #36735.