提交 d30897b8 编写于 作者: U ustcwelcome 提交者: 奏之章

bug-fix of markcompaction

上级 a4d77e92
......@@ -932,9 +932,9 @@ void DBImpl::ScheduleGCTTL() {
auto should_marked_for_compacted = [&](uint64_t ratio_expire_time,
uint64_t scan_gap_expire_time,
uint64_t now) {
ROCKS_LOG_INFO(immutable_db_options_.info_log,
"SST Table property info:%" PRIu64 ",%" PRIu64 ",%" PRIu64,
ratio_expire_time, scan_gap_expire_time, now);
// ROCKS_LOG_INFO(immutable_db_options_.info_log,
// "SST Table property info:%" PRIu64 ",%" PRIu64 ",%"
// PRIu64, ratio_expire_time, scan_gap_expire_time, now);
return (std::min(ratio_expire_time, scan_gap_expire_time) <= now);
};
ROCKS_LOG_INFO(immutable_db_options_.info_log, "Start ScheduleGCTTL");
......@@ -945,26 +945,35 @@ void DBImpl::ScheduleGCTTL() {
VersionStorageInfo* vsi = cfd->current()->storage_info();
for (int l = 0; l < vsi->num_levels(); l++) {
for (auto sst : vsi->LevelFiles(l)) {
if (sst->marked_for_compaction) marked_count++;
if (!sst->marked_for_compaction)
sst->marked_for_compaction = should_marked_for_compacted(
sst->prop.ratio_expire_time, sst->prop.scan_gap_expire_time,
nowSeconds);
if (sst->marked_for_compaction) {
marked_count++;
} else if (should_marked_for_compacted(sst->prop.ratio_expire_time,
sst->prop.scan_gap_expire_time,
nowSeconds)) {
sst->marked_for_compaction = true;
}
if (sst->marked_for_compaction) {
TEST_SYNC_POINT("DBImpl:ScheduleGCTTL-mark");
mark_count++;
}
}
}
if (mark_count > 0) {
vsi->ComputeCompactionScore(*cfd->ioptions(),
*cfd->GetLatestMutableCFOptions());
InstrumentedMutexLock l(&mutex_);
AddToCompactionQueue(cfd);
unscheduled_compactions_++;
MaybeScheduleFlushOrCompaction();
}
ROCKS_LOG_INFO(immutable_db_options_.info_log,
"[%s] marked for compact SST: %d, %d, %d",
cfd->GetName().c_str(), marked_count, mark_count, cnt);
marked_count = 0;
mark_count = 0;
cnt = 0;
}
}
ROCKS_LOG_INFO(immutable_db_options_.info_log,
"marked for compact SST: %d,%d,%d", marked_count, mark_count,
cnt);
if (mark_count > 0) {
InstrumentedMutexLock l(&mutex_);
MaybeScheduleFlushOrCompaction();
}
}
void DBImpl::DumpStats() {
TEST_SYNC_POINT("DBImpl::DumpStats:1");
......
......@@ -71,7 +71,7 @@ int FindFileInRange(const InternalKeyComparator& icmp,
uint32_t left, uint32_t right) {
return static_cast<int>(
terark::lower_bound_ex_n(file_level.files, left, right, key,
TERARK_FIELD(largest_key), "" < icmp));
TERARK_FIELD(largest_key), "" < icmp));
}
Status OverlapWithIterator(const Comparator* ucmp,
......@@ -2117,8 +2117,7 @@ void VersionStorageInfo::GenerateLevel0NonOverlapping() {
level_files_brief_[0].files,
level_files_brief_[0].files + level_files_brief_[0].num_files);
auto icmp = internal_comparator_;
terark::sort_a(level0_sorted_file,
TERARK_FIELD(smallest_key) < *icmp);
terark::sort_a(level0_sorted_file, TERARK_FIELD(smallest_key) < *icmp);
for (size_t i = 1; i < level0_sorted_file.size(); ++i) {
FdWithKeyRange& f = level0_sorted_file[i];
......@@ -2167,18 +2166,22 @@ void VersionStorageInfo::ComputeBottommostFilesMarkedForCompaction() {
bottommost_files_marked_for_compaction_.clear();
bottommost_files_mark_threshold_ = kMaxSequenceNumber;
for (auto& level_and_file : bottommost_files_) {
if (!level_and_file.second->being_compacted &&
level_and_file.second->fd.largest_seqno != 0 &&
level_and_file.second->prop.num_deletions > 1) {
// largest_seqno might be nonzero due to containing the final key in an
// earlier compaction, whose seqnum we didn't zero out. Multiple deletions
// ensures the file really contains deleted or overwritten keys.
if (level_and_file.second->fd.largest_seqno < oldest_snapshot_seqnum_) {
if (!level_and_file.second->being_compacted) {
if (level_and_file.second->fd.largest_seqno != 0 &&
level_and_file.second->prop.num_deletions > 1) {
// largest_seqno might be nonzero due to containing the final key in an
// earlier compaction, whose seqnum we didn't zero out. Multiple
// deletions ensures the file really contains deleted or overwritten
// keys.
if (level_and_file.second->fd.largest_seqno < oldest_snapshot_seqnum_) {
bottommost_files_marked_for_compaction_.push_back(level_and_file);
} else {
bottommost_files_mark_threshold_ =
std::min(bottommost_files_mark_threshold_,
level_and_file.second->fd.largest_seqno);
}
} else if (level_and_file.second->marked_for_compaction) {
bottommost_files_marked_for_compaction_.push_back(level_and_file);
} else {
bottommost_files_mark_threshold_ =
std::min(bottommost_files_mark_threshold_,
level_and_file.second->fd.largest_seqno);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册