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
This commit is contained in:
parent
a7d4eb2f34
commit
bf1c4089db
@ -3,11 +3,11 @@
|
|||||||
// LICENSE file in the root directory of this source tree. An additional grant
|
// 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.
|
// of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
|
||||||
|
#include "util/thread_status_updater.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "rocksdb/env.h"
|
#include "rocksdb/env.h"
|
||||||
#include "port/likely.h"
|
#include "port/likely.h"
|
||||||
#include "util/mutexlock.h"
|
#include "util/mutexlock.h"
|
||||||
#include "util/thread_status_updater.h"
|
|
||||||
|
|
||||||
namespace rocksdb {
|
namespace rocksdb {
|
||||||
|
|
||||||
@ -246,7 +246,9 @@ void ThreadStatusUpdater::EraseColumnFamilyInfo(const void* cf_key) {
|
|||||||
// a consistent view of global column family table (cf_info_map).
|
// a consistent view of global column family table (cf_info_map).
|
||||||
std::lock_guard<std::mutex> lck(thread_list_mutex_);
|
std::lock_guard<std::mutex> lck(thread_list_mutex_);
|
||||||
auto cf_pair = cf_info_map_.find(cf_key);
|
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();
|
auto* cf_info = cf_pair->second.get();
|
||||||
assert(cf_info);
|
assert(cf_info);
|
||||||
@ -278,7 +280,9 @@ void ThreadStatusUpdater::EraseDatabaseInfo(const void* db_key) {
|
|||||||
size_t result __attribute__((unused)) = 0;
|
size_t result __attribute__((unused)) = 0;
|
||||||
for (auto cf_key : db_pair->second) {
|
for (auto cf_key : db_pair->second) {
|
||||||
auto cf_pair = cf_info_map_.find(cf_key);
|
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();
|
cf_pair->second.reset();
|
||||||
result = cf_info_map_.erase(cf_key);
|
result = cf_info_map_.erase(cf_key);
|
||||||
assert(result);
|
assert(result);
|
||||||
|
Loading…
Reference in New Issue
Block a user