When an index thread receives an interrupt during init before it got to index anything (so m_best_block_index == nullptr
still), it will still try to commit previous “work” before stopping the thread. That means that BaseIndex::CommitInternal()
calls GetLocator(nullptr)
, which returns an locator to the tip (code), and saves it to the index DB.
On the next startup, this locator will be read and it will be assumed that we have successfully synced the index to the tip, when in reality we have indexed nothing.
In the case of coinstatsindex, this would lead to a shutdown of bitcoind without any indication what went wrong. For the other indexes, there would be no immediate shutdown, but the index would be corrupt.
This PR fixes this by not committing when m_best_block_index==nullptr
, and it also adds an error log message to the silent coinstatsindex shutdown path.
This is another small bug found by feature_init.py
- the second commit enables blockfilterindex and coinstatsindex for this test, enabling coinstatsindex without the first commit would have led to frequent failures.