CancelAllBackgroundWork before Close in db stress (#6174)

Summary:
Close asserts that there is no unreleased snapshots. For WritePrepared transaction, this means that the background work that holds on a snapshot must be canceled first. Update the stress tests to respect the sequence.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6174

Test Plan:
```
make -j32 crash_test

Differential Revision: D19057322

Pulled By: maysamyabandeh

fbshipit-source-id: c9e9e24f779bbfb0ab72c2717e34576c01bc6362
This commit is contained in:
Maysam Yabandeh 2019-12-13 17:56:12 -08:00 committed by Facebook Github Bot
parent edbf0e2d90
commit 349bd3ed82

View file

@ -1759,8 +1759,10 @@ void StressTest::Open() {
void StressTest::Reopen(ThreadState* thread) {
#ifndef ROCKSDB_LITE
bool bg_canceled = false;
if (thread->rand.OneIn(2)) {
CancelAllBackgroundWork(db_, static_cast<bool>(thread->rand.OneIn(2)));
bg_canceled = true;
}
#else
(void) thread;
@ -1772,7 +1774,9 @@ void StressTest::Reopen(ThreadState* thread) {
column_families_.clear();
#ifndef ROCKSDB_LITE
if (thread->rand.OneIn(2)) {
// 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)) {
Status s = db_->Close();
if (!s.ok()) {
fprintf(stderr, "Non-ok close status: %s\n", s.ToString().c_str());