From a8b1085ae20e437633683517da3200437de3fd30 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Tue, 7 Jan 2020 13:45:21 -0800 Subject: [PATCH] Fix test in LITE mode (#6267) Summary: Currently, the recently-added test DBTest2.SwitchMemtableRaceWithNewManifest fails in LITE mode since SetOptions() returns "Not supported". I do not want to put `#ifndef ROCKSDB_LITE` because it reduces test coverage. Instead, just trigger compaction on a different column family. The bg compaction thread calling LogAndApply() may race with thread calling SwitchMemtable(). Test Plan (dev server): make check OPT=-DROCKSDB_LITE make check or run DBTest2.SwitchMemtableRaceWithNewManifest 100 times. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6267 Differential Revision: D19301309 Pulled By: riversand963 fbshipit-source-id: 88cedcca2f985968ed3bb234d324ffa2aa04ca50 --- db/db_test2.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/db_test2.cc b/db/db_test2.cc index 0b7fdb44b..8095330d2 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -4255,9 +4255,17 @@ TEST_F(DBTest2, SwitchMemtableRaceWithNewManifest) { options.max_manifest_file_size = 10; options.create_if_missing = true; CreateAndReopenWithCF({"pikachu"}, options); + ASSERT_EQ(2, handles_.size()); + ASSERT_OK(Put("foo", "value")); + const int kL0Files = options.level0_file_num_compaction_trigger; + for (int i = 0; i < kL0Files; ++i) { + ASSERT_OK(Put(/*cf=*/1, "a", std::to_string(i))); + ASSERT_OK(Flush(/*cf=*/1)); + } + port::Thread thread([&]() { ASSERT_OK(Flush()); }); - ASSERT_OK(dbfull()->SetOptions({{"prefix_extractor", "fixed:5"}})); + ASSERT_OK(dbfull()->TEST_WaitForCompact()); thread.join(); } } // namespace rocksdb