Cancel bg jobs before deleting WritePrepared DB in stress tests (#6355)

Summary:
Background jobs in WritePrepared DB might access the db via a snapshot checker callback. The stress tests therefore should cancel background jobs before deleting the db in ::Reopen.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6355

Differential Revision: D19664132

Pulled By: maysamyabandeh

fbshipit-source-id: 6060a830e8aad0015c10448286ad37c8a346ac01
main
Maysam Yabandeh 5 years ago committed by Facebook Github Bot
parent 3316d29221
commit 2243030bc5
  1. 14
      db_stress_tool/db_stress_test_base.cc

@ -2073,12 +2073,18 @@ void StressTest::Open() {
void StressTest::Reopen(ThreadState* thread) {
#ifndef ROCKSDB_LITE
// BG jobs in WritePrepared must be canceled first because i) they can access
// the db via a callbac ii) they hold on to a snapshot and the upcoming
// ::Close would complain about it.
const bool write_prepared = FLAGS_use_txn && FLAGS_txn_write_policy != 0;
bool bg_canceled = false;
if (thread->rand.OneIn(2)) {
const bool wait = static_cast<bool>(thread->rand.OneIn(2));
if (write_prepared || thread->rand.OneIn(2)) {
const bool wait =
write_prepared || static_cast<bool>(thread->rand.OneIn(2));
CancelAllBackgroundWork(db_, wait);
bg_canceled = wait;
}
assert(!write_prepared || bg_canceled);
#else
(void) thread;
#endif
@ -2089,9 +2095,7 @@ void StressTest::Reopen(ThreadState* thread) {
column_families_.clear();
#ifndef ROCKSDB_LITE
// BG jobs in WritePrepared hold on to a snapshot
const bool write_prepared = FLAGS_use_txn && FLAGS_txn_write_policy != 0;
if (thread->rand.OneIn(2) && (!write_prepared || bg_canceled)) {
if (thread->rand.OneIn(2)) {
Status s = db_->Close();
if (!s.ok()) {
fprintf(stderr, "Non-ok close status: %s\n", s.ToString().c_str());

Loading…
Cancel
Save