Skip CancelAllBackgroundWork if DBImpl is already closed (#6268)

Summary:
WritePreparedTxnDB calls CancelAllBackgroundWork in its destructor to avoid dangling references to it from background job's SnapshotChecker callback. However, if the DBImpl is already closed, the info log might be closed with it, which causes memory leak when CancelAllBackgroundWork tries to print to the info log. The patch fixes that by calling CancelAllBackgroundWork only if the db is not closed already.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6268

Differential Revision: D19303439

Pulled By: maysamyabandeh

fbshipit-source-id: 4228a6be7e78d43c90630347baa89b008200bd15
main
Maysam Yabandeh 5 years ago committed by Facebook Github Bot
parent 1ab1231acf
commit 5709e97a74
  1. 2
      utilities/transactions/write_prepared_txn_db.cc

@ -970,7 +970,9 @@ WritePreparedTxnDB::~WritePreparedTxnDB() {
// At this point there could be running compaction/flush holding a // At this point there could be running compaction/flush holding a
// SnapshotChecker, which holds a pointer back to WritePreparedTxnDB. // SnapshotChecker, which holds a pointer back to WritePreparedTxnDB.
// Make sure those jobs finished before destructing WritePreparedTxnDB. // Make sure those jobs finished before destructing WritePreparedTxnDB.
if (!db_impl_->shutting_down_) {
db_impl_->CancelAllBackgroundWork(true /*wait*/); db_impl_->CancelAllBackgroundWork(true /*wait*/);
}
} }
void SubBatchCounter::InitWithComp(const uint32_t cf) { void SubBatchCounter::InitWithComp(const uint32_t cf) {

Loading…
Cancel
Save