HomePhabricator

index: make indices robust against init aborts

Description

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

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D12622

Details

Provenance
Martin Zumsande <mzumsande@gmail.com>Authored on Jan 20 2022, 21:21
PiRKCommitted on Nov 25 2022, 17:00
PiRKPushed on Nov 25 2022, 17:00
Reviewer
Restricted Project
Differential Revision
D12622: index: make indices robust against init aborts
Parents
rABCd1010e755da6: test: bump timeouts for feature_block and feature_abortnode
Branches
Unknown
Tags
Unknown