From bf1c4089db50abe1f19bf0d92efff6b0afb430d3 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Fri, 4 Mar 2016 16:03:31 -0800 Subject: [PATCH] Use pure if-then check instead of assert in EraseColumnFamilyInfo Summary: Use pure if-then check instead of assert in EraseColumnFamilyInfo when the specified column family does not found in the cf_info_map_. So the second deletion will be no op instead of crash. Test Plan: existing test. Reviewers: sdong, anthony, kradhakrishnan, IslamAbdelRahman Reviewed By: IslamAbdelRahman Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D55023 --- util/thread_status_updater.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/util/thread_status_updater.cc b/util/thread_status_updater.cc index 375b2f321..a3f9a9afc 100644 --- a/util/thread_status_updater.cc +++ b/util/thread_status_updater.cc @@ -3,11 +3,11 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. +#include "util/thread_status_updater.h" #include #include "rocksdb/env.h" #include "port/likely.h" #include "util/mutexlock.h" -#include "util/thread_status_updater.h" namespace rocksdb { @@ -246,7 +246,9 @@ void ThreadStatusUpdater::EraseColumnFamilyInfo(const void* cf_key) { // a consistent view of global column family table (cf_info_map). std::lock_guard lck(thread_list_mutex_); auto cf_pair = cf_info_map_.find(cf_key); - assert(cf_pair != cf_info_map_.end()); + if (cf_pair == cf_info_map_.end()) { + return; + } auto* cf_info = cf_pair->second.get(); assert(cf_info); @@ -278,7 +280,9 @@ void ThreadStatusUpdater::EraseDatabaseInfo(const void* db_key) { size_t result __attribute__((unused)) = 0; for (auto cf_key : db_pair->second) { auto cf_pair = cf_info_map_.find(cf_key); - assert(cf_pair != cf_info_map_.end()); + if (cf_pair == cf_info_map_.end()) { + continue; + } cf_pair->second.reset(); result = cf_info_map_.erase(cf_key); assert(result);