diff options
author | Andrew Chow <github@achow101.com> | 2023-09-01 13:17:42 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-09-01 13:25:01 -0400 |
commit | df98a12fc2af11b25d8e57ab8c3a233b532acabc (patch) | |
tree | d57183d4ceec88f3a7e700e696c811d34ae0b77e /src | |
parent | b2f1d732cb17429a632692ee824127983da718aa (diff) | |
parent | df60de770d8e27c00eced29d8a4a4bce7c6e4b30 (diff) |
Merge bitcoin/bitcoin#28350: Log explicit error message when coindb is found in inconsistent state
df60de770d8e27c00eced29d8a4a4bce7c6e4b30 log: Print error message when coindb is in inconsistent state (Fabian Jahr)
Pull request description:
While doing manual testing on assumeutxo this week I managed to put the coindb into an inconsistent state twice. For a normal user, this can also happen if their computer crashes during a flush or if they try to stop their node during a flush and then get tired of waiting and just shut their computer down or kill the process. It's an edge case but I wouldn't be surprised if this does happen more often when assumeutxo gets used more widely because there might be multiple flushes happening during loading of the UTXO set in the beginning and users may think something is going wrong because of the unexpected wait or they forgot some configs and want to start over quickly.
The problem is, when this happens at first the node starts up normally until it's time to flush again and then it hits an assert that the user can not understand.
```
2023-08-25T16:31:09Z [httpworker.0] [snapshot] 52000000 coins loaded (43.30%, 6768 MB)
2023-08-25T16:31:16Z [httpworker.0] Cache size (7272532192) exceeds total space (7256510300)
2023-08-25T16:31:16Z [httpworker.0] FlushSnapshotToDisk: flushing coins cache (7272 MB) started
Assertion failed: (old_heads[0] == hashBlock), function BatchWrite, file txdb.cpp, line 126.
Abort trap: 6
```
We should at least log an error message that gives users a hint of what the problem is and what they can do to resolve it. I am keeping this separate from the assumeutxo project since this issue can also happen during any regular flush.
ACKs for top commit:
jonatack:
ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30
achow101:
ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30
ryanofsky:
Code review ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30
jamesob:
Code review ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30
Tree-SHA512: b546aa0b0323ece2962867a29c38e014ac83ae8f1ded090da2894b4ff2450c05229629c7e8892f7b550cf7def4038a0b4119812e548e11b00c60b1dc3d4276d2
Diffstat (limited to 'src')
-rw-r--r-- | src/txdb.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index e5b5e0b8a1..538c4d8f07 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -123,6 +123,9 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, boo // We may be in the middle of replaying. std::vector<uint256> old_heads = GetHeadBlocks(); if (old_heads.size() == 2) { + if (old_heads[0] != hashBlock) { + LogPrintLevel(BCLog::COINDB, BCLog::Level::Error, "The coins database detected an inconsistent state, likely due to a previous crash or shutdown. You will need to restart bitcoind with the -reindex-chainstate or -reindex configuration option.\n"); + } assert(old_heads[0] == hashBlock); old_tip = old_heads[1]; } |