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
This commit is contained in:
Maysam Yabandeh 2020-01-07 15:33:05 -08:00 committed by Facebook Github Bot
parent 1ab1231acf
commit 5709e97a74

View File

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