WritePrepare Txn: Cancel flush/compaction before destruction

Summary:
On WritePreparedTxnDB destruct there could be running compaction/flush holding a SnapshotChecker, which holds a pointer back to WritePreparedTxnDB. Make sure those jobs finished before destructing WritePreparedTxnDB.

This is caught by TransactionTest::SeqAdvanceTest.
Closes https://github.com/facebook/rocksdb/pull/2982

Differential Revision: D6002957

Pulled By: yiwu-arbug

fbshipit-source-id: f1e70390c9798d1bd7959f5c8e2a1c14100773c3
main
Yi Wu 7 years ago committed by Facebook Github Bot
parent ec6c5383d0
commit 17c6325e8a
  1. 7
      utilities/transactions/pessimistic_transaction_db.cc
  2. 2
      utilities/transactions/pessimistic_transaction_db.h

@ -954,5 +954,12 @@ bool WritePreparedTxnDB::MaybeUpdateOldCommitMap(
return next_is_larger; return next_is_larger;
} }
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*/);
}
} // namespace rocksdb } // namespace rocksdb
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

@ -191,7 +191,7 @@ class WritePreparedTxnDB : public PessimisticTransactionDB {
Init(txn_db_options); Init(txn_db_options);
} }
virtual ~WritePreparedTxnDB() {} virtual ~WritePreparedTxnDB();
virtual Status Initialize( virtual Status Initialize(
const std::vector<size_t>& compaction_enabled_cf_indices, const std::vector<size_t>& compaction_enabled_cf_indices,

Loading…
Cancel
Save