From 349bd3ed8219246c8f1318c6fdfd7e193e3eb01d Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Fri, 13 Dec 2019 17:56:12 -0800 Subject: [PATCH] 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 --- db_stress_tool/db_stress_test_base.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 112258ff7f..767097ee0b 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -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(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());