Fix Transaction memory leak

Summary:
- Make sure we clean up recovered_transactions_ on DBImpl destructor
- delete leaked txns and env in TransactionTest

Test Plan: Run transaction_test under valgrind

Reviewers: sdong, andrewkr, yhchiang, horuff

Reviewed By: horuff

Subscribers: andrewkr, dhruba

Differential Revision: https://reviews.facebook.net/D58263
main
Islam AbdelRahman 9 years ago
parent a08c8c851a
commit f6aedb62c0
  1. 4
      db/db_impl.cc
  2. 6
      utilities/transactions/transaction_test.cc

@ -460,6 +460,10 @@ DBImpl::~DBImpl() {
// so the cache can be safely destroyed.
table_cache_->EraseUnRefEntries();
for (auto& txn_entry : recovered_transactions_) {
delete txn_entry.second;
}
// versions need to be destroyed before table_cache since it can hold
// references to table_cache.
versions_.reset();

@ -57,6 +57,7 @@ class TransactionTest : public testing::Test {
~TransactionTest() {
delete db;
DestroyDB(dbname, options);
delete env_;
}
Status ReOpenNoDelete() {
@ -442,6 +443,8 @@ TEST_F(TransactionTest, TwoPhaseRollbackTest) {
// try rollback again
s = txn->Rollback();
ASSERT_EQ(s, Status::InvalidArgument());
delete txn;
}
TEST_F(TransactionTest, PersistentTwoPhaseTransactionTest) {
@ -495,6 +498,7 @@ TEST_F(TransactionTest, PersistentTwoPhaseTransactionTest) {
s = db->Get(read_options, Slice("foo"), &value);
ASSERT_TRUE(s.IsNotFound());
delete txn;
// kill and reopen
s = ReOpenNoDelete();
ASSERT_OK(s);
@ -735,6 +739,8 @@ TEST_F(TransactionTest, TwoPhaseDoubleRecoveryTest) {
s = txn->Commit();
ASSERT_OK(s);
delete txn;
// kill and reopen
env_->SetFilesystemActive(false);
ReOpenNoDelete();

Loading…
Cancel
Save