Repository navigation
db: report unreadable coin metadata and keys as errors - #334
Merged
minuszka merged 1 commit intoOct 28, 2026
Merged
Conversation
A present head-blocks marker that did not decode, or named no block, looked like a consistent coin database, so replay after an interrupted flush could be skipped. The coins cursor could return a partly decoded first key and treated a damaged later key as the end of the coins, so statistics, scans and exports could finish on part of the UTXO set. A failed reopen during a cache resize left the view without a database while the new sizes were already recorded. Add CDBWrapper::TryRead() from Bitcoin Core #34931 (commit 5dfbb91b) to tell a missing value from an undecodable one. Report undecodable or empty head-blocks markers and damaged coin keys as database errors. Reopen with the previous size if a resize fails, report a database that stays closed as an error, and record new cache sizes only after a successful reopen. Fault-injection tests cover each case. Healthy databases, their formats and consensus rules are unchanged. Co-authored-by: furszy <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The coin database could mistake damaged local data for normal states. A present but undecodable or empty head-blocks marker looked like a consistent database, so the replay of an interrupted flush could be skipped. The coins cursor could return a partly decoded first key and treated a damaged later key as the end of the coins, so UTXO statistics, scans and snapshot exports could finish on part of the set. A failed reopen during a cache resize left the coin view without a database and its new sizes already recorded.
What changes:
CDBWrapper::TryRead()from Bitcoin Core #34931 tells a missing value from an undecodable one;Read()keeps its existing behavior. Undecodable or empty head-blocks markers and damaged coin keys are now reported as database errors, which stop startup or the RPC call instead of being treated as absent data. If a cache resize cannot reopen the database, it reopens with the previous size; a database that stays closed reports an error on use, and new cache sizes are recorded only after a successful reopen.What stays the same: Healthy databases behave as before. Database formats, RPC and P2P interfaces and consensus rules are unchanged.
Validation: Independently reviewed and approved. Fault-injection tests cover truncated, count-only and empty head-blocks markers, damaged first and later coin keys and trailing key data, UTXO statistics over a damaged key, and single and double reopen failures, at the coin view and chainstate level. The unchanged code fails the corresponding tests, and the earlier review round's code fails the two cases added during review. All 11 final local CI gates passed, including 827 unit cases, strict unit and Qt leak checks, the required functional tests, and the configure and no-wallet gates; all five commit-lint checks passed.
The
TryRead()backport adapts furszy's upstream commit to this fork; the author is credited in the commit.