Skip to content

Commit

Permalink
Use pure if-then check instead of assert in EraseColumnFamilyInfo
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yhchiang committed Mar 5, 2016
1 parent a7d4eb2 commit bf1c408
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions util/thread_status_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>
#include "rocksdb/env.h"
#include "port/likely.h"
#include "util/mutexlock.h"
#include "util/thread_status_updater.h"

namespace rocksdb {

Expand Down Expand Up @@ -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<std::mutex> 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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bf1c408

Please sign in to comment.