提交 7d906799 编写于 作者: S Sagar Vemuri 提交者: Facebook Github Bot

Ttl-triggered and snapshot-release-triggered compactions should not be manual compactions

Summary:
Ttl-triggered and snapshot-release-triggered compactions should not be considered as manual compactions. This is a bug.
Closes https://github.com/facebook/rocksdb/pull/3678

Differential Revision: D7498151

Pulled By: sagar0

fbshipit-source-id: a2d5bed05268a4dc93d54ea97a9ae44b366df15d
上级 2a62ca17
...@@ -1172,11 +1172,11 @@ void LevelCompactionBuilder::SetupInitialFiles() { ...@@ -1172,11 +1172,11 @@ void LevelCompactionBuilder::SetupInitialFiles() {
// if we didn't find a compaction, check if there are any files marked for // if we didn't find a compaction, check if there are any files marked for
// compaction // compaction
if (start_level_inputs_.empty()) { if (start_level_inputs_.empty()) {
is_manual_ = true;
parent_index_ = base_index_ = -1; parent_index_ = base_index_ = -1;
PickFilesMarkedForCompaction(); PickFilesMarkedForCompaction();
if (!start_level_inputs_.empty()) { if (!start_level_inputs_.empty()) {
is_manual_ = true;
compaction_reason_ = CompactionReason::kFilesMarkedForCompaction; compaction_reason_ = CompactionReason::kFilesMarkedForCompaction;
return; return;
} }
......
...@@ -3091,6 +3091,13 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) { ...@@ -3091,6 +3091,13 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) {
// compactions should be triggered, which reduce the size of each bottom-level // compactions should be triggered, which reduce the size of each bottom-level
// file without changing file count. // file without changing file count.
db_->ReleaseSnapshot(snapshot); db_->ReleaseSnapshot(snapshot);
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg);
ASSERT_TRUE(compaction->compaction_reason() ==
CompactionReason::kBottommostFiles);
});
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
db_->GetLiveFilesMetaData(&post_release_metadata); db_->GetLiveFilesMetaData(&post_release_metadata);
ASSERT_EQ(pre_release_metadata.size(), post_release_metadata.size()); ASSERT_EQ(pre_release_metadata.size(), post_release_metadata.size());
...@@ -3104,6 +3111,7 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) { ...@@ -3104,6 +3111,7 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) {
// deletion markers/deleted keys. // deletion markers/deleted keys.
ASSERT_LT(post_file.size, pre_file.size); ASSERT_LT(post_file.size, pre_file.size);
} }
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) { TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
...@@ -3153,9 +3161,16 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) { ...@@ -3153,9 +3161,16 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
// compacted. // compacted.
ASSERT_OK(Put("a", "1")); ASSERT_OK(Put("a", "1"));
Flush(); Flush();
rocksdb::SyncPoint::GetInstance()->SetCallBack(
"LevelCompactionPicker::PickCompaction:Return", [&](void* arg) {
Compaction* compaction = reinterpret_cast<Compaction*>(arg);
ASSERT_TRUE(compaction->compaction_reason() == CompactionReason::kTtl);
});
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
// All non-L0 files are deleted, as they contained only deleted data. // All non-L0 files are deleted, as they contained only deleted data.
ASSERT_EQ("1", FilesPerLevel()); ASSERT_EQ("1", FilesPerLevel());
rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
TEST_F(DBCompactionTest, CompactRangeDelayedByL0FileCount) { TEST_F(DBCompactionTest, CompactRangeDelayedByL0FileCount) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册