This avoids situations during a reindex, in which the shutdown doesn't finish since LimitValidationInterfaceQueue() is called by the load block thread when the scheduler is already stopped, in which case it would block indefinitely. This can lead to intermittent failures in feature_reindex.py (#30424), which I could locally reproduce with
diff --git a/src/validation.cpp b/src/validation.cpp
index 74f0e4975c..be1706fdaf 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3446,6 +3446,7 @@ static void LimitValidationInterfaceQueue(ValidationSignals& signals) LOCKS_EXCL
AssertLockNotHeld(cs_main);
if (signals.CallbacksPending() > 10) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
signals.SyncWithValidationInterfaceQueue();
}
}
It has also been reported by users running reindex-chainstate (#23234).
I thought for a bit about potential downsides of changing this order, but couldn't find any.