[EventEngine] ThreadPool: pause closure execution on fork events (#31994)

* [EventEngine] ThreadPool: pause execution of closures on fork

* update tests

* iwyu

* disable test

* iwyu
pull/32064/head
AJ Heller 2 years ago committed by GitHub
parent 5fc92eaeae
commit 91cb4a941b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/core/lib/event_engine/thread_pool.cc
  2. 8
      test/core/event_engine/thread_pool_test.cc

@ -128,8 +128,9 @@ bool ThreadPool::Queue::Step() {
switch (state_) {
case State::kRunning:
break;
case State::kShutdown:
case State::kForking:
return false;
case State::kShutdown:
if (!callbacks_.empty()) break;
return false;
}

@ -66,10 +66,9 @@ TEST(ThreadPoolTest, CanSurviveFork) {
});
gpr_log(GPR_INFO, "prepare fork");
p.PrepareFork();
gpr_log(GPR_INFO, "wait for notification");
n.WaitForNotification();
gpr_log(GPR_INFO, "postfork child");
p.PostforkChild();
n.WaitForNotification();
grpc_core::Notification n2;
gpr_log(GPR_INFO, "run callback 3");
p.Run([&n2] {
@ -85,7 +84,10 @@ void ScheduleSelf(ThreadPool* p) {
p->Run([p] { ScheduleSelf(p); });
}
TEST(ThreadPoolDeathTest, CanDetectStucknessAtFork) {
// This can be re-enabled if/when the thread pool is changed to quiesce
// pre-fork. For now, it cannot get stuck because callback execution is
// effectively paused until after the post-fork reboot.
TEST(ThreadPoolDeathTest, DISABLED_CanDetectStucknessAtFork) {
ASSERT_DEATH_IF_SUPPORTED(
[] {
gpr_set_log_verbosity(GPR_LOG_SEVERITY_ERROR);

Loading…
Cancel
Save