From 1049c9e53b361f5c5ebc9cecd8450910fdc4b2ff Mon Sep 17 00:00:00 2001 From: Lingxuan Zuo Date: Tue, 28 Jul 2020 11:21:10 +0800 Subject: [PATCH] [Stats] fix stats shutdown crash if opencensus exporter not initialized (#9727) --- src/ray/stats/stats.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ray/stats/stats.h b/src/ray/stats/stats.h index 668288a58..629087b11 100644 --- a/src/ray/stats/stats.h +++ b/src/ray/stats/stats.h @@ -103,6 +103,10 @@ static inline void Init(const TagsType &global_tags, const int metrics_agent_por static inline void Shutdown() { // TODO(sang): Harvest thread is not currently cleaned up. absl::MutexLock lock(&stats_mutex); + if (!StatsConfig::instance().IsInitialized()) { + // Return if stats had never been initialized. + return; + } metrics_io_service_pool->Stop(); opencensus::stats::StatsExporter::Shutdown(); metrics_io_service_pool = nullptr;