diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 2fa150dc8..cf6346efb 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -11,6 +11,7 @@ #ifdef GFLAGS #include "db_stress_tool/db_stress_common.h" #include "db_stress_tool/db_stress_driver.h" +#include "rocksdb/convenience.h" namespace rocksdb { StressTest::StressTest() @@ -485,7 +486,7 @@ void StressTest::OperateDb(ThreadState* thread) { } thread->shared->IncVotedReopen(); if (thread->shared->AllVotedReopen()) { - thread->shared->GetStressTest()->Reopen(); + thread->shared->GetStressTest()->Reopen(thread); thread->shared->GetCondVar()->SignalAll(); } else { thread->shared->GetCondVar()->Wait(); @@ -1746,11 +1747,26 @@ void StressTest::Open() { } } -void StressTest::Reopen() { +void StressTest::Reopen(ThreadState* thread) { +#ifndef ROCKSDB_LITE + if (thread->rand.OneIn(2)) { + CancelAllBackgroundWork(db_, static_cast(thread->rand.OneIn(2))); + } +#else + (void) thread; +#endif + for (auto cf : column_families_) { delete cf; } column_families_.clear(); + +#ifndef ROCKSDB_LITE + if (thread->rand.OneIn(2)) { + Status s = db_->Close(); + assert(s.ok()); + } +#endif delete db_; db_ = nullptr; #ifndef ROCKSDB_LITE diff --git a/db_stress_tool/db_stress_test_base.h b/db_stress_tool/db_stress_test_base.h index 664fa5705..869405a67 100644 --- a/db_stress_tool/db_stress_test_base.h +++ b/db_stress_tool/db_stress_test_base.h @@ -171,7 +171,7 @@ class StressTest { void Open(); - void Reopen(); + void Reopen(ThreadState* thread); std::shared_ptr cache_; std::shared_ptr compressed_cache_;