fix: Proper shutdown sequence with Namespaces (#3333)

This removes a race between periodic fiber and namespaces during
shutdown.
This commit is contained in:
Shahar Mike 2024-07-17 16:58:22 +03:00 committed by GitHub
parent e3eb8518fd
commit 4898b25b49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 5 deletions

View file

@ -396,12 +396,16 @@ void EngineShard::Shutdown() {
tiered_storage_.reset();
}
DCHECK(!fiber_periodic_.IsJoinable());
ProactorBase::me()->RemoveOnIdleTask(defrag_task_);
}
void EngineShard::StopPeriodicFiber() {
fiber_periodic_done_.Notify();
if (fiber_periodic_.IsJoinable()) {
fiber_periodic_.Join();
}
ProactorBase::me()->RemoveOnIdleTask(defrag_task_);
}
void EngineShard::StartPeriodicFiber(util::ProactorBase* pb) {
@ -895,6 +899,10 @@ void EngineShardSet::Init(uint32_t sz, bool update_db_time) {
});
}
void EngineShardSet::PreShutdown() {
RunBlockingInParallel([](EngineShard* shard) { shard->StopPeriodicFiber(); });
}
void EngineShardSet::Shutdown() {
RunBlockingInParallel([](EngineShard*) { EngineShard::DestroyThreadLocal(); });
}