diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -250,6 +250,9 @@ // After everything has been shut down, but before things get flushed, stop // the CScheduler/checkqueue threadGroup + if (node.scheduler) { + node.scheduler->stop(); + } threadGroup.interrupt_all(); threadGroup.join_all(); diff --git a/src/test/txindex_tests.cpp b/src/test/txindex_tests.cpp --- a/src/test/txindex_tests.cpp +++ b/src/test/txindex_tests.cpp @@ -75,6 +75,8 @@ // shutdown sequence (c.f. Shutdown() in init.cpp) txindex.Stop(); + // txindex job may be scheduled, so stop scheduler before destructing + m_node.scheduler->stop(); threadGroup.interrupt_all(); threadGroup.join_all(); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -143,6 +143,9 @@ } TestingSetup::~TestingSetup() { + if (m_node.scheduler) { + m_node.scheduler->stop(); + } threadGroup.interrupt_all(); threadGroup.join_all(); GetMainSignals().FlushBackgroundCallbacks();