|
@ -786,7 +786,7 @@ TEST_F(DBTest, GetEncountersEmptyLevel) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Step 2: clear level 1 if necessary.
|
|
|
// Step 2: clear level 1 if necessary.
|
|
|
dbfull()->TEST_CompactRange(1, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(1, nullptr, nullptr, false); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 1); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 1); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(1), 0); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(1), 0); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(2), 1); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(2), 1); |
|
@ -1145,7 +1145,7 @@ TEST_F(DBTest, CompactionsGenerateMultipleFiles) { |
|
|
|
|
|
|
|
|
// Reopening moves updates to level-0
|
|
|
// Reopening moves updates to level-0
|
|
|
Reopen(&options); |
|
|
Reopen(&options); |
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr, false); |
|
|
|
|
|
|
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0); |
|
|
ASSERT_GT(NumTableFilesAtLevel(1), 1); |
|
|
ASSERT_GT(NumTableFilesAtLevel(1), 1); |
|
@ -1196,7 +1196,7 @@ TEST_F(DBTest, SparseMerge) { |
|
|
} |
|
|
} |
|
|
Put("C", "vc"); |
|
|
Put("C", "vc"); |
|
|
dbfull()->TEST_CompactMemTable(); |
|
|
dbfull()->TEST_CompactMemTable(); |
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr, false); |
|
|
|
|
|
|
|
|
// Make sparse update
|
|
|
// Make sparse update
|
|
|
Put("A", "va2"); |
|
|
Put("A", "va2"); |
|
@ -1207,9 +1207,9 @@ TEST_F(DBTest, SparseMerge) { |
|
|
// Compactions should not cause us to create a situation where
|
|
|
// Compactions should not cause us to create a situation where
|
|
|
// a file overlaps too much data at the next level.
|
|
|
// a file overlaps too much data at the next level.
|
|
|
ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20 * 1048576); |
|
|
ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20 * 1048576); |
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr, false); |
|
|
ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20 * 1048576); |
|
|
ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20 * 1048576); |
|
|
dbfull()->TEST_CompactRange(1, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(1, nullptr, nullptr, false); |
|
|
ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20 * 1048576); |
|
|
ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20 * 1048576); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1273,7 +1273,7 @@ TEST_F(DBTest, ApproximateSizes) { |
|
|
std::string cend_str = Key(compact_start + 9); |
|
|
std::string cend_str = Key(compact_start + 9); |
|
|
Slice cstart = cstart_str; |
|
|
Slice cstart = cstart_str; |
|
|
Slice cend = cend_str; |
|
|
Slice cend = cend_str; |
|
|
dbfull()->TEST_CompactRange(0, &cstart, &cend); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, &cstart, &cend, false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0); |
|
@ -1320,7 +1320,7 @@ TEST_F(DBTest, ApproximateSizes_MixOfSmallAndLarge) { |
|
|
|
|
|
|
|
|
ASSERT_TRUE(Between(Size(Key(3), Key(5)), 110000, 111000)); |
|
|
ASSERT_TRUE(Between(Size(Key(3), Key(5)), 110000, 111000)); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, nullptr, nullptr, false); |
|
|
} |
|
|
} |
|
|
} while (ChangeOptions()); |
|
|
} while (ChangeOptions()); |
|
|
} |
|
|
} |
|
@ -1397,11 +1397,11 @@ TEST_F(DBTest, HiddenValuesAreRemoved) { |
|
|
db_->ReleaseSnapshot(snapshot); |
|
|
db_->ReleaseSnapshot(snapshot); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ tiny, " + big + " ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ tiny, " + big + " ]"); |
|
|
Slice x("x"); |
|
|
Slice x("x"); |
|
|
dbfull()->TEST_CompactRange(0, nullptr, &x); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(0, nullptr, &x, false); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ tiny ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ tiny ]"); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0); |
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0); |
|
|
ASSERT_GE(NumTableFilesAtLevel(1), 1); |
|
|
ASSERT_GE(NumTableFilesAtLevel(1), 1); |
|
|
dbfull()->TEST_CompactRange(1, nullptr, &x); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(1, nullptr, &x, false); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ tiny ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ tiny ]"); |
|
|
|
|
|
|
|
|
ASSERT_TRUE(Between(Size("", "pastfoo"), 0, 1000)); |
|
|
ASSERT_TRUE(Between(Size("", "pastfoo"), 0, 1000)); |
|
@ -1427,11 +1427,11 @@ TEST_F(DBTest, DeletionMarkers1) { |
|
|
ASSERT_LEVELDB_OK(dbfull()->TEST_CompactMemTable()); // Moves to level last-2
|
|
|
ASSERT_LEVELDB_OK(dbfull()->TEST_CompactMemTable()); // Moves to level last-2
|
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ v2, DEL, v1 ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ v2, DEL, v1 ]"); |
|
|
Slice z("z"); |
|
|
Slice z("z"); |
|
|
dbfull()->TEST_CompactRange(last - 2, nullptr, &z); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(last - 2, nullptr, &z, false); |
|
|
// DEL eliminated, but v1 remains because we aren't compacting that level
|
|
|
// DEL eliminated, but v1 remains because we aren't compacting that level
|
|
|
// (DEL can be eliminated because v2 hides v1).
|
|
|
// (DEL can be eliminated because v2 hides v1).
|
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ v2, v1 ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ v2, v1 ]"); |
|
|
dbfull()->TEST_CompactRange(last - 1, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(last - 1, nullptr, nullptr, false); |
|
|
// Merging last-1 w/ last, so we are the base level for "foo", so
|
|
|
// Merging last-1 w/ last, so we are the base level for "foo", so
|
|
|
// DEL is removed. (as is v1).
|
|
|
// DEL is removed. (as is v1).
|
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ v2 ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ v2 ]"); |
|
@ -1454,10 +1454,10 @@ TEST_F(DBTest, DeletionMarkers2) { |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); |
|
|
ASSERT_LEVELDB_OK(dbfull()->TEST_CompactMemTable()); // Moves to level last-2
|
|
|
ASSERT_LEVELDB_OK(dbfull()->TEST_CompactMemTable()); // Moves to level last-2
|
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); |
|
|
dbfull()->TEST_CompactRange(last - 2, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(last - 2, nullptr, nullptr, false); |
|
|
// DEL kept: "last" file overlaps
|
|
|
// DEL kept: "last" file overlaps
|
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ DEL, v1 ]"); |
|
|
dbfull()->TEST_CompactRange(last - 1, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(last - 1, nullptr, nullptr, false); |
|
|
// Merging last-1 w/ last, so we are the base level for "foo", so
|
|
|
// Merging last-1 w/ last, so we are the base level for "foo", so
|
|
|
// DEL is removed. (as is v1).
|
|
|
// DEL is removed. (as is v1).
|
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ ]"); |
|
|
ASSERT_EQ(AllEntriesFor("foo"), "[ ]"); |
|
@ -1491,8 +1491,8 @@ TEST_F(DBTest, OverlapInLevel0) { |
|
|
ASSERT_EQ("2,1,1", FilesPerLevel()); |
|
|
ASSERT_EQ("2,1,1", FilesPerLevel()); |
|
|
|
|
|
|
|
|
// Compact away the placeholder files we created initially
|
|
|
// Compact away the placeholder files we created initially
|
|
|
dbfull()->TEST_CompactRange(1, nullptr, nullptr); |
|
|
|
|
|
dbfull()->TEST_CompactRange(2, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(1, nullptr, nullptr, false); |
|
|
|
|
|
dbfull()->TEST_CompactRange(2, nullptr, nullptr, false); |
|
|
ASSERT_EQ("2", FilesPerLevel()); |
|
|
ASSERT_EQ("2", FilesPerLevel()); |
|
|
|
|
|
|
|
|
// Do a memtable compaction. Before bug-fix, the compaction would
|
|
|
// Do a memtable compaction. Before bug-fix, the compaction would
|
|
@ -1787,7 +1787,7 @@ TEST_F(DBTest, NoSpace) { |
|
|
env_->no_space_.store(true, std::memory_order_release); |
|
|
env_->no_space_.store(true, std::memory_order_release); |
|
|
for (int i = 0; i < 10; i++) { |
|
|
for (int i = 0; i < 10; i++) { |
|
|
for (int level = 0; level < config::kNumLevels - 1; level++) { |
|
|
for (int level = 0; level < config::kNumLevels - 1; level++) { |
|
|
dbfull()->TEST_CompactRange(level, nullptr, nullptr); |
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(level, nullptr, nullptr, false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
env_->no_space_.store(false, std::memory_order_release); |
|
|
env_->no_space_.store(false, std::memory_order_release); |
|
@ -1876,7 +1876,7 @@ TEST_F(DBTest, ManifestWriteError) { |
|
|
|
|
|
|
|
|
// Merging compaction (will fail)
|
|
|
// Merging compaction (will fail)
|
|
|
error_type->store(true, std::memory_order_release); |
|
|
error_type->store(true, std::memory_order_release); |
|
|
dbfull()->TEST_CompactRange(last, nullptr, nullptr); // Should fail
|
|
|
|
|
|
|
|
|
dbfull()->TEST_CompactRange(last, nullptr, nullptr, false); // Should fail
|
|
|
ASSERT_EQ("bar", Get("foo")); |
|
|
ASSERT_EQ("bar", Get("foo")); |
|
|
|
|
|
|
|
|
// Recovery: should not lose data
|
|
|
// Recovery: should not lose data
|
|
|