Fix DropColumnFamily data race
Summary: It should hold db mutex while accessing max_total_in_memory_state_. Closes https://github.com/facebook/rocksdb/pull/2784 Differential Revision: D5696536 Pulled By: yiwu-arbug fbshipit-source-id: 45430634d7fe11909b38e42e5f169f618681c4ee
This commit is contained in:
parent
7fdf735d5d
commit
92bfd6c507
@ -1324,6 +1324,11 @@ Status DBImpl::DropColumnFamilyImpl(ColumnFamilyHandle* column_family) {
|
|||||||
&edit, &mutex_);
|
&edit, &mutex_);
|
||||||
write_thread_.ExitUnbatched(&w);
|
write_thread_.ExitUnbatched(&w);
|
||||||
}
|
}
|
||||||
|
if (s.ok()) {
|
||||||
|
auto* mutable_cf_options = cfd->GetLatestMutableCFOptions();
|
||||||
|
max_total_in_memory_state_ -= mutable_cf_options->write_buffer_size *
|
||||||
|
mutable_cf_options->max_write_buffer_number;
|
||||||
|
}
|
||||||
|
|
||||||
if (!cf_support_snapshot) {
|
if (!cf_support_snapshot) {
|
||||||
// Dropped Column Family doesn't support snapshot. Need to recalculate
|
// Dropped Column Family doesn't support snapshot. Need to recalculate
|
||||||
@ -1345,9 +1350,6 @@ Status DBImpl::DropColumnFamilyImpl(ColumnFamilyHandle* column_family) {
|
|||||||
// later inside db_mutex.
|
// later inside db_mutex.
|
||||||
EraseThreadStatusCfInfo(cfd);
|
EraseThreadStatusCfInfo(cfd);
|
||||||
assert(cfd->IsDropped());
|
assert(cfd->IsDropped());
|
||||||
auto* mutable_cf_options = cfd->GetLatestMutableCFOptions();
|
|
||||||
max_total_in_memory_state_ -= mutable_cf_options->write_buffer_size *
|
|
||||||
mutable_cf_options->max_write_buffer_number;
|
|
||||||
ROCKS_LOG_INFO(immutable_db_options_.info_log,
|
ROCKS_LOG_INFO(immutable_db_options_.info_log,
|
||||||
"Dropped column family with id %u\n", cfd->GetID());
|
"Dropped column family with id %u\n", cfd->GetID());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user