Fix test failure of reduce_num_levels

Summary:
I changed the reduce_num_levels logic to avoid "compactRange()" call if the current number of levels in use (levels that contain files) is smaller than the new num of levels.
And that change breaks the assert in reduce_levels_test

Test Plan: run reduce_levels_test

Reviewers: dhruba, MarkCallaghan

Reviewed By: dhruba

CC: emayanke, sheki

Differential Revision: https://reviews.facebook.net/D6651
This commit is contained in:
heyongqiang 2012-11-11 22:33:22 -08:00
parent 9c6c232e47
commit c64796fd34
3 changed files with 2 additions and 7 deletions

View File

@ -118,21 +118,16 @@ TEST(ReduceLevelTest, Top_Level) {
ASSERT_EQ(FilesOnLevel(0), 1); ASSERT_EQ(FilesOnLevel(0), 1);
CloseDB(); CloseDB();
// The CompactRange(NULL, NULL) call in ReduceLevels
// will push this file to level-1
ASSERT_TRUE(ReduceLevels(4)); ASSERT_TRUE(ReduceLevels(4));
ASSERT_OK(OpenDB(true, 4, 0)); ASSERT_OK(OpenDB(true, 4, 0));
ASSERT_EQ(FilesOnLevel(1), 1);
CloseDB(); CloseDB();
ASSERT_TRUE(ReduceLevels(3)); ASSERT_TRUE(ReduceLevels(3));
ASSERT_OK(OpenDB(true, 3, 0)); ASSERT_OK(OpenDB(true, 3, 0));
ASSERT_EQ(FilesOnLevel(1), 1);
CloseDB(); CloseDB();
ASSERT_TRUE(ReduceLevels(2)); ASSERT_TRUE(ReduceLevels(2));
ASSERT_OK(OpenDB(true, 2, 0)); ASSERT_OK(OpenDB(true, 2, 0));
ASSERT_EQ(FilesOnLevel(1), 1);
CloseDB(); CloseDB();
} }

View File

@ -252,7 +252,7 @@ leveldb::Options ReduceDBLevels::PrepareOptionsForOpenDB() {
leveldb::Options opt = LDBCommand::PrepareOptionsForOpenDB(); leveldb::Options opt = LDBCommand::PrepareOptionsForOpenDB();
opt.num_levels = old_levels_; opt.num_levels = old_levels_;
// Disable size compaction // Disable size compaction
opt.max_bytes_for_level_base = 1L << 60; opt.max_bytes_for_level_base = 1UL << 50;
opt.max_bytes_for_level_multiplier = 1; opt.max_bytes_for_level_multiplier = 1;
opt.max_mem_compaction_level = 0; opt.max_mem_compaction_level = 0;
return opt; return opt;