diff --git a/src/ray/gcs/gcs_server/test/gcs_server_rpc_test.cc b/src/ray/gcs/gcs_server/test/gcs_server_rpc_test.cc index 8411ebbbca85..cabad9872701 100644 --- a/src/ray/gcs/gcs_server/test/gcs_server_rpc_test.cc +++ b/src/ray/gcs/gcs_server/test/gcs_server_rpc_test.cc @@ -63,6 +63,7 @@ class GcsServerTest : public ::testing::Test { gcs_server_->Stop(); thread_io_service_->join(); gcs_server_.reset(); + ray::gcs::RedisCallbackManager::instance().Clear(); } bool AddJob(const rpc::AddJobRequest &request) { diff --git a/src/ray/gcs/redis_context.cc b/src/ray/gcs/redis_context.cc index 1f964543806d..a16e35f90d48 100644 --- a/src/ray/gcs/redis_context.cc +++ b/src/ray/gcs/redis_context.cc @@ -212,6 +212,11 @@ std::shared_ptr RedisCallbackManager::GetCal return it->second; } +void RedisCallbackManager::Clear() { + std::lock_guard lock(mutex_); + callback_items_.clear(); +} + void RedisCallbackManager::RemoveCallback(int64_t callback_index) { std::lock_guard lock(mutex_); callback_items_.erase(callback_index); diff --git a/src/ray/gcs/redis_context.h b/src/ray/gcs/redis_context.h index 7c4f350219f5..f3fc9328a1f1 100644 --- a/src/ray/gcs/redis_context.h +++ b/src/ray/gcs/redis_context.h @@ -145,6 +145,9 @@ class RedisCallbackManager { /// Get a callback. std::shared_ptr GetCallback(int64_t callback_index) const; + /// Clear all callbacks. + void Clear(); + private: RedisCallbackManager() : num_callbacks_(0){};