Reading a block from disk does not require cs_main
, so it can be removed or held shorter in functions that read from disk.
This is the first commit stolen from #11913 without rebase or otherwise touching it.
Reading a block from disk does not require cs_main
, so it can be removed or held shorter in functions that read from disk.
This is the first commit stolen from #11913 without rebase or otherwise touching it.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
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.
So in that case pruning would succeed and in that case LGTM.
If fs::remove
throws then the process terminates, otherwise CBlockIndex
state turns wrong — which would require restart to fix?
I’ll try to reproduce.
178@@ -179,6 +179,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
179 if (!GetTransaction(hash, tx, Params().GetConsensus(), hash_block, true, blockindex)) {
180 std::string errmsg;
181 if (blockindex) {
182+ LOCK(cs_main);
It seems there is a race condition if the block is pruned after GetBlockPos
is called and before the block file is actually opened:
On unix it should be sufficient to just hold onto cs_main
until after the block file is opened but before it is read, but on windows I’m not sure.