-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect and handle corrupt or missing blocks or indexes #537
Comments
What I think about this issue: |
If it's known where the block is, wouldn't it be a better option to invalidate it and then reconsider it after connecting to peers, rather than having the user down for 12-20 hours with a reindex? |
Based on my tests, 1 common problem is when they are out of sync at the end. i.e. block written to disk but the daemon dies before writing the index. That I believe could be solved without re-indexing everything if we choose to do so. Another problem is when the files get damaged in the middle. At that point, it becomes very difficult to trust anything after that point. A download across the wire and a re-index is probably inevitable at that point. As for 2 phase commit, that is a possible solution. There are actual journaling filesystem libraries that can help with that. I am unsure if any open-source libraries exist for that, but I imagine so. Or we could roll our own. The "costs" of such a solution must be weighed (i.e. maintenance). |
I think we should try and test the revalidation proposal |
Situation:
When a node encounters a problem, the block files or index files can become corrupted or have incomplete data.
Weapons:
Corruption and missing data can be detected. Other nodes can provide the information the corrupted node lacks.
Objective:
Detect the problem and repair it before allowing the node to report that it is fully synchronized.
Tactics:
-reindex
option.Where we are now:
Some situations of block or index corruption are detected, others are not.
As an example, having the node crash after writing the block to disk but before the index file is written will lead to missing transactions when the node restarts. The node does restart, but the data is inaccurate. Looking for the block returns
nullptr
and looking for a transaction that was within that block returns that the transaction does not exist.Additional Information:
The function
LoadIndexDB()
does some checks to verify the integrity of the block files. This may be a good place to add additional checks to verify that the blocks and the index are synchronized.Note: The attempt is to assist node operators when hardware/software issues make a mess within the persisted data on disk. Detecting malicious modification to distort data is not considered here.
Note: Having a block who's previous block does not exist may not be an indication of corruption. It is a valid (temporary) situation that must be planned for.
In my testing:
ToDo:
See also:
Bitcoin issue 19274
The text was updated successfully, but these errors were encountered: