Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix some chainstate-init-order bugs. #10758
Conversation
|
Note that the two generic "Error initializing block database" strings really should be changed, but as we are already in string freeze for 0.15, they will have to stay as-is for now :(. |
fanquake
added the
Refactoring
label
Jul 7, 2017
|
More explicitly fixed the bug that I accidentally fixed by being more explicit - RewindBlockIndex MUST be called even if we start with -reindex-chainstate. |
TheBlueMatt
referenced
this pull request
Jul 7, 2017
Merged
Use non-atomic flushing with block replay #10148
|
This needs an 0.15 tag as it fixes some bugs. |
TheBlueMatt
referenced
this pull request
Jul 16, 2017
Open
Drop upgrade-cancel callback registration for a generic "cancelable" #10770
|
Rebased and added a fix for the issue @sipa pointed out at #10770 (comment) |
| + } | ||
| + | ||
| + if (needs_init) { | ||
| + // Note that LoadBlockIndexDB may have set fReindex if we shut down |
|
@TheBlueMatt When starting with |
|
ACK @TheBlueMatt I retract my comment, everything seems to be working like before. |
|
I'd like to see this in 0.15 as it at least turns an assert into an error message, in case your chainstate is out of sync with the block chain. |
|
This (or some subset of it) absolutely has to land for 15, it fixes several regressions currently on master, but its a bugfix, so doesn't need to land today (but isnt small, so should go sooner rather than later). |
sipa
added this to the
0.15.0
milestone
Jul 17, 2017
sipa
referenced
this pull request
Jul 18, 2017
Open
Segfault on shutdown after pressing 'q' to postpone utxo db upgrade #10861
|
I haven't finished reviewing, but this also fixes a crash when using an invalid -wallet argument. For example: |
|
utACK c93db42 Strongly advocate for merging this in the near term. |
laanwj
added
to Blockers in High-priority for review
Jul 20, 2017
|
In current master running
With this branch gives
Reporting this here because of c93db42. |
|
@sipa hmm, re: restarting-mid-reindex: your original comment that it was broken was more correct than your later retraction. Fixed and cleaned that stuff up more with more comments :). |
|
@TheBlueMatt if it's not related with your refactor then IMO a new PR would be best. |
|
OK, removed the top two commits so this is just what it was that got ACKs. The two commits from the top are in #10919, which should likely also be taken for 15. |
|
reutACK c93db42 |
laanwj
added the
Bug
label
Jul 25, 2017
| + if (!ReceivedBlockTransactions(block, state, pindex, blockPos, chainparams.GetConsensus())) | ||
| + return error("LoadBlockIndex(): genesis block not accepted"); | ||
| + } catch (const std::runtime_error& e) { | ||
| + return error("LoadBlockIndex(): failed to initialize block database: %s", e.what()); |
laanwj
Jul 27, 2017
Owner
This error is no longer correct, this is "failed to load genesis block" now I guess?
| + CDiskBlockPos blockPos; | ||
| + CValidationState state; | ||
| + if (!FindBlockPos(state, blockPos, nBlockSize+8, 0, block.GetBlockTime())) | ||
| + return error("LoadBlockIndex(): FindBlockPos failed"); |
laanwj
Jul 27, 2017
Owner
Would be better to use error("%s: ...", __func__) here as in other places, but in any case, the function name is wrong now.
|
utACK apart from error message nits |
TheBlueMatt
added some commits
Jul 6, 2017
|
Fixed error printings in LoadGenesisBlock. |
|
re-utACK c0025d0 |
TheBlueMatt commentedJul 7, 2017
•
edited
This does a number of things to clean up chainstate init order,
fixing some issues as it goes:
Order chainstate init more logically - first all of the
blocktree-related loading, then coinsdb, then
pcoinsTip/chainActive. Only create objects as needed.
More clearly document exactly what is and isn't called in
-reindex and -reindex-chainstate both with comments noting
calls as no-ops and by adding if guards.
Move the writing of fTxIndex to LoadBlockIndex - this fixes a
bug introduced in d6af06d where
InitBlockIndex was writing to fTxIndex which had not yet been
checked (because LoadChainTip hadn't yet initialized the
chainActive, which would otherwise have resulted in
InitBlockIndex being a NOP), allowing you to modify -txindex
without reindex, potentially corrupting your chainstate!
Rename InitBlockIndex to LoadGenesisBlock, which is now a more
natural name for it. Also check mapBlockIndex instead of
chainActive, fixing a bug where we'd write the genesis block out
on every start.
Move LoadGenesisBlock further down in init. This is a more logical
location for it, as it is after all of the blockindex-related
loading and checking, but before any of the UTXO-related loading
and checking.
Give LoadChainTip a return value - allowing it to indicate that
the UTXO DB ran ahead of the block DB. This just provides a nicer
error message instead of the previous mysterious
assert(!setBlockIndexCandidates.empty()) error.
Calls ActivateBestChain in case we just loaded the genesis
block in LoadChainTip, avoiding relying on the ActivateBestChain
in ThreadImport before continuing init process.
Move all of the VerifyDB()-related stuff into a -reindex +
-reindex-chainstate if guard. It couldn't do anything useful
as chainActive.Tip() would be null at this point anyway.