db_stress: sometimes call CancelAllBackgroundWork() and Close() before closing DB (#6141)
Summary: CancelAllBackgroundWork() and Close() are frequently used features but we don't cover it in stress test. Simply execute them before closing the DB with 1/2 chance. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6141 Test Plan: Run "db_stress". Differential Revision: D18900861 fbshipit-source-id: 49b46ccfae120d0f9de3e0543b82fb6d715949d0
This commit is contained in:
parent
984b6e71d6
commit
7a99162a74
@ -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<bool>(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
|
||||
|
@ -171,7 +171,7 @@ class StressTest {
|
||||
|
||||
void Open();
|
||||
|
||||
void Reopen();
|
||||
void Reopen(ThreadState* thread);
|
||||
|
||||
std::shared_ptr<Cache> cache_;
|
||||
std::shared_ptr<Cache> compressed_cache_;
|
||||
|
Loading…
Reference in New Issue
Block a user