From d3bb572da6430ef77bc789c0a22554b87a84e909 Mon Sep 17 00:00:00 2001 From: krad Date: Thu, 3 Dec 2015 19:05:13 -0800 Subject: [PATCH] Build break fix. Summary: Skip list now cannot estimate memory across allocators consistently and hence triggers flush at different time. This breaks certain unit tests. The fix is to adopt key count instead of size for flush. Test Plan: Ran test on dev box and mac (where it used to fail) Reviewers: sdong CC: leveldb@ Task ID: #9273334 Blame Rev: --- db/db_test_util.cc | 4 ++-- db/db_test_util.h | 1 + db/db_universal_compaction_test.cc | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/db/db_test_util.cc b/db/db_test_util.cc index 0e29cb2e4..bfed4de40 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -833,7 +833,7 @@ int DBTestBase::GetSstFileCount(std::string path) { // this will generate non-overlapping files since it keeps increasing key_idx void DBTestBase::GenerateNewFile(int cf, Random* rnd, int* key_idx, bool nowait) { - for (int i = 0; i < 100; i++) { + for (int i = 0; i < KNumKeysByGenerateNewFile; i++) { ASSERT_OK(Put(cf, Key(*key_idx), RandomString(rnd, (i == 99) ? 1 : 990))); (*key_idx)++; } @@ -845,7 +845,7 @@ void DBTestBase::GenerateNewFile(int cf, Random* rnd, int* key_idx, // this will generate non-overlapping files since it keeps increasing key_idx void DBTestBase::GenerateNewFile(Random* rnd, int* key_idx, bool nowait) { - for (int i = 0; i < 100; i++) { + for (int i = 0; i < KNumKeysByGenerateNewFile; i++) { ASSERT_OK(Put(Key(*key_idx), RandomString(rnd, (i == 99) ? 1 : 990))); (*key_idx)++; } diff --git a/db/db_test_util.h b/db/db_test_util.h index 8b22eee5f..b52e43ce9 100644 --- a/db/db_test_util.h +++ b/db/db_test_util.h @@ -710,6 +710,7 @@ class DBTestBase : public testing::Test { void GenerateNewFile(int fd, Random* rnd, int* key_idx, bool nowait = false); static const int kNumKeysByGenerateNewRandomFile; + static const int KNumKeysByGenerateNewFile = 100; void GenerateNewRandomFile(Random* rnd, bool nowait = false); diff --git a/db/db_universal_compaction_test.cc b/db/db_universal_compaction_test.cc index bc18a49b9..1c2100428 100644 --- a/db/db_universal_compaction_test.cc +++ b/db/db_universal_compaction_test.cc @@ -890,6 +890,8 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionFourPaths) { options.db_paths.emplace_back(dbname_ + "_2", 300 * 1024); options.db_paths.emplace_back(dbname_ + "_3", 500 * 1024); options.db_paths.emplace_back(dbname_ + "_4", 1024 * 1024 * 1024); + options.memtable_factory.reset( + new SpecialSkipListFactory(KNumKeysByGenerateNewFile - 1)); options.compaction_style = kCompactionStyleUniversal; options.compaction_options_universal.size_ratio = 5; options.write_buffer_size = 110 << 10; // 105KB