diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 4089c0acb9a..4c0798531e7 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -690,11 +690,14 @@ Status DBImpl::CloseHelper() { delete txn_entry.second; } + mutex_.Unlock(); // We can only access cf_based_write_buffer_manager_ before versions_.reset(), // after which all cf write buffer managers will be freed. for (auto m : cf_based_write_buffer_manager_) { m->UnregisterDB(this); } + mutex_.Lock(); + // versions need to be destroyed before table_cache since it can hold // references to table_cache. versions_.reset(); diff --git a/include/rocksdb/write_buffer_manager.h b/include/rocksdb/write_buffer_manager.h index f2b93d8aa55..444e383080d 100644 --- a/include/rocksdb/write_buffer_manager.h +++ b/include/rocksdb/write_buffer_manager.h @@ -141,6 +141,8 @@ class WriteBufferManager final { } } + // Must ensure that the mutex of all dbs except this_db are not held. If + // this_db is not nullptr, the mutex of it must be held. void MaybeFlushLocked(DB* this_db = nullptr); // Returns true if total memory usage exceeded buffer_size.