提交 2243030b 编写于 作者: M Maysam Yabandeh 提交者: Facebook Github Bot

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
上级 3316d292
......@@ -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());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册