Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hx235 committed Dec 19, 2023
1 parent fd3a66e commit 807f119
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions db/compaction/compaction_service_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,36 @@ class CompactionServiceTest : public DBTestBase {
std::shared_ptr<CompactionService> compaction_service_;
};

TEST_F(CompactionServiceTest, ResumeBasic1) {
Options options = CurrentOptions();
options.target_file_size_base = 1 << 5; // 1KB
ReopenWithCompactionService(&options);

ASSERT_OK(Put("k1", "old"));
ASSERT_OK(Flush());
ASSERT_OK(Put("k1", "new"));
ASSERT_OK(Flush());

std::vector<LiveFileMetaData> metadata;

SyncPoint::GetInstance()->SetCallBack(
"DBImplSecondary::CompactWithoutInstallation::End", [&](void* status) {
// override job status
auto s = static_cast<Status*>(status);
*s = Status::Aborted("MyTestCompactionService failed to compact!");
});
SyncPoint::GetInstance()->EnableProcessing();
ASSERT_NOK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
SyncPoint::GetInstance()->ClearAllCallBacks();
SyncPoint::GetInstance()->DisableProcessing();

db_->GetLiveFilesMetaData(&metadata);
ASSERT_EQ(metadata.size(), 2);
Reopen(options);
dbfull()->TEST_WaitForCompact();
ASSERT_EQ(metadata.size(), 1);
}

TEST_F(CompactionServiceTest, BasicCompactions) {
Options options = CurrentOptions();
options.max_subcompactions = 2;
Expand Down
3 changes: 2 additions & 1 deletion db/version_edit_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ Status VersionEditHandler::ExtractInfoFromVersionEdit(ColumnFamilyData* cfd,
cfd->SetFullHistoryTsLow(new_ts);
}
if (cfd->ioptions()->resume_compaction &&
edit.HasResumableCompactionInfo()) {
edit.HasResumableCompactionInfo() &&
cfd->ioptions()->compaction_service != nullptr) {
cfd->AddResumableCompaction(edit.GetResumableCompactionInfo());
}
}
Expand Down

0 comments on commit 807f119

Please sign in to comment.