Fix flaky test ShuttingDownNotBlockStalledWrites (#10800)

Summary:
DBTest::ShuttingDownNotBlockStalledWrites is flaky, added new sync point dependency to fix it.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10800

Test Plan: gtest-parallel --repeat=1000 ./db_test --gtest_filter="*ShuttingDownNotBlockStalledWrites"

Reviewed By: jay-zhuang

Differential Revision: D40239116

Pulled By: jay-zhuang

fbshipit-source-id: 8c2d7e7df58f202d287bd9f5c9b60b7eff270d0c
main
Changyu Bi 2 years ago committed by Facebook GitHub Bot
parent 62ba5c8034
commit a6ce1955b1
  1. 32
      db/db_test.cc

@ -7217,25 +7217,26 @@ TEST_F(DBTest, ShuttingDownNotBlockStalledWrites) {
Reopen(options); Reopen(options);
Random rnd(403); Random rnd(403);
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"BackgroundCallCompaction:1",
[&](void* /* arg */) { env_->SleepForMicroseconds(2 * 1000 * 1000); });
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::DelayWrite:Wait",
"DBTest::ShuttingDownNotBlockStalledWrites"}});
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 100; j++) { ASSERT_OK(Put("key_" + std::to_string(i), rnd.RandomString(10)));
std::string value = rnd.RandomString(1000); ASSERT_OK(Flush());
ASSERT_OK(Put("key_" + std::to_string(j), value));
}
Flush();
} }
ASSERT_EQ(GetSstFileCount(dbname_), 20); ASSERT_EQ(GetSstFileCount(dbname_), 20);
// We need !disable_auto_compactions for writes to stall but also want to
// delay compaction so stalled writes unblocked due to kShutdownInProgress. BG
// compaction will first wait for the sync point
// DBTest::ShuttingDownNotBlockStalledWrites. Then it waits extra 2 sec to
// allow CancelAllBackgroundWork() to set shutting_down_.
SyncPoint::GetInstance()->SetCallBack(
"BackgroundCallCompaction:0",
[&](void* /* arg */) { env_->SleepForMicroseconds(2 * 1000 * 1000); });
SyncPoint::GetInstance()->LoadDependency(
{{"DBImpl::DelayWrite:Wait", "DBTest::ShuttingDownNotBlockStalledWrites"},
{"DBTest::ShuttingDownNotBlockStalledWrites",
"BackgroundCallCompaction:0"}});
SyncPoint::GetInstance()->EnableProcessing();
options.level0_stop_writes_trigger = 20; options.level0_stop_writes_trigger = 20;
options.disable_auto_compactions = false; options.disable_auto_compactions = false;
Reopen(options); Reopen(options);
@ -7247,7 +7248,6 @@ TEST_F(DBTest, ShuttingDownNotBlockStalledWrites) {
TEST_SYNC_POINT("DBTest::ShuttingDownNotBlockStalledWrites"); TEST_SYNC_POINT("DBTest::ShuttingDownNotBlockStalledWrites");
CancelAllBackgroundWork(db_, true); CancelAllBackgroundWork(db_, true);
LogFlush(options.info_log);
thd.join(); thd.join();
} }

Loading…
Cancel
Save