init: Stop indexes on shutdown after ChainStateFlushed callback.
Currently, the latest index state may not be committed to disk on shutdown. Github-Pull: #17897 Rebased-From: 9dd58ca611f6f2b59c25d727a4e955333525d345
This commit is contained in:
parent
98159132c3
commit
9d980c1f7f
1 changed files with 8 additions and 4 deletions
12
src/init.cpp
12
src/init.cpp
|
@ -199,8 +199,6 @@ void Shutdown(InitInterfaces& interfaces)
|
|||
// using the other before destroying them.
|
||||
if (peerLogic) UnregisterValidationInterface(peerLogic.get());
|
||||
if (g_connman) g_connman->Stop();
|
||||
if (g_txindex) g_txindex->Stop();
|
||||
ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Stop(); });
|
||||
|
||||
StopTorControl();
|
||||
|
||||
|
@ -214,8 +212,6 @@ void Shutdown(InitInterfaces& interfaces)
|
|||
peerLogic.reset();
|
||||
g_connman.reset();
|
||||
g_banman.reset();
|
||||
g_txindex.reset();
|
||||
DestroyAllBlockFilterIndexes();
|
||||
|
||||
if (::mempool.IsLoaded() && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
||||
DumpMempool(::mempool);
|
||||
|
@ -248,6 +244,14 @@ void Shutdown(InitInterfaces& interfaces)
|
|||
// CValidationInterface callbacks, flush them...
|
||||
GetMainSignals().FlushBackgroundCallbacks();
|
||||
|
||||
// Stop and delete all indexes only after flushing background callbacks.
|
||||
if (g_txindex) {
|
||||
g_txindex->Stop();
|
||||
g_txindex.reset();
|
||||
}
|
||||
ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Stop(); });
|
||||
DestroyAllBlockFilterIndexes();
|
||||
|
||||
// Any future callbacks will be dropped. This should absolutely be safe - if
|
||||
// missing a callback results in an unrecoverable situation, unclean shutdown
|
||||
// would too. The only reason to do the above flushes is to let the wallet catch
|
||||
|
|
Loading…
Reference in a new issue