From 78528bd60972f7c5fe333afe4857acfa8e4166bc Mon Sep 17 00:00:00 2001 From: Tyler Neely Date: Wed, 2 Nov 2022 17:12:21 +0000 Subject: [PATCH] Avoid the ShutDown explicit acknowledgement due to jthread already blocking on this --- src/storage/v3/shard_manager.hpp | 12 +----------- src/storage/v3/shard_worker.hpp | 11 +++-------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/storage/v3/shard_manager.hpp b/src/storage/v3/shard_manager.hpp index 4d7507e87..559f51afe 100644 --- a/src/storage/v3/shard_manager.hpp +++ b/src/storage/v3/shard_manager.hpp @@ -84,8 +84,6 @@ class ShardManager { : io_(io), coordinator_leader_(coordinator_leader) { MG_ASSERT(shard_worker_threads >= 1); - shard_worker::Queue queue; - for (int i = 0; i < shard_worker_threads; i++) { shard_worker::Queue queue; shard_worker::ShardWorker worker{io, queue}; @@ -103,16 +101,8 @@ class ShardManager { ShardManager &operator=(const ShardManager &) = delete; ~ShardManager() { - auto shutdown_acks = std::vector>{}; for (auto worker : workers_) { - auto [future, promise] = io::FuturePromisePair(); - worker.Push(shard_worker::ShutDown{.acknowledge_shutdown = std::move(promise)}); - shutdown_acks.emplace_back(std::move(future)); - } - - for (auto &&ack : shutdown_acks) { - bool acked = std::move(ack).Wait(); - MG_ASSERT(acked); + worker.Push(shard_worker::ShutDown{}); } // The jthread handes for our shard worker threads will be diff --git a/src/storage/v3/shard_worker.hpp b/src/storage/v3/shard_worker.hpp index ae590c541..4cca118e7 100644 --- a/src/storage/v3/shard_worker.hpp +++ b/src/storage/v3/shard_worker.hpp @@ -55,9 +55,7 @@ using storage::v3::ShardRsm; template using ShardRaft = Raft; -struct ShutDown { - io::Promise acknowledge_shutdown; -}; +struct ShutDown {}; struct Cron {}; @@ -96,7 +94,7 @@ class Queue { { std::unique_lock lock(inner_->mu); - inner_->queue.push_back(std::forward(message)); + inner_->queue.emplace_back(std::forward(message)); } // lock dropped before notifying condition variable inner_->cv.notify_all(); @@ -125,10 +123,7 @@ class ShardWorker { Time next_cron_ = Time::min(); std::map> rsm_map_; - bool Process(ShutDown &&shut_down) { - shut_down.acknowledge_shutdown.Fill(true); - return false; - } + bool Process(ShutDown && /* shut_down */) { return false; } bool Process(Cron &&cron) { Cron();