Page MenuHomePhabricator

index: make indices robust against init aborts
ClosedPublic

Authored by PiRK on Nov 25 2022, 10:31.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC6175151d3aef: index: make indices robust against init aborts
Summary

PR description:

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.

commits:

index: Don't commit without valid m_best_block_index

Also report an error when coinstatsindex init fails.

test: activate all index types in feature_init.py

This is a backport of core#24117
Depends on D12621

Test Plan

ninja all check-all