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

[bug] bug-fix and it's a runnable version for myrocks (#5)

上级 d341588b
......@@ -880,13 +880,22 @@ Status CompactionJob::Run() {
output.meta.prop.read_amp = tp->read_amp;
output.meta.prop.dependence = tp->dependence;
output.meta.prop.inheritance_chain = tp->inheritance_chain;
output.meta.prop.ratio_expire_time = tp->ratio_expire_time;
output.meta.prop.scan_gap_expire_time = tp->scan_gap_expire_time;
// ROCKS_LOG_INFO(db_options_.info_log,
// "ratio:%" PRIu64 ", scan:%" PRIu64,
// tp->ratio_expire_time, tp->scan_gap_expire_time);
output.finished = true;
c->AddOutputTableFileNumber(file_number);
if (iopt->ttl_extractor_factory != nullptr) {
output.meta.prop.ratio_expire_time = DecodeFixed64(
tp->user_collected_properties
.find(TablePropertiesNames::kEarliestTimeBeginCompact)
->second.c_str());
output.meta.prop.scan_gap_expire_time = DecodeFixed64(
tp->user_collected_properties
.find(TablePropertiesNames::kLatestTimeEndCompact)
->second.c_str());
ROCKS_LOG_INFO(db_options_.info_log,
"compaction_run ratio:%" PRIu64 ", scan:%" PRIu64,
output.meta.prop.ratio_expire_time,
output.meta.prop.scan_gap_expire_time);
output.finished = true;
c->AddOutputTableFileNumber(file_number);
}
}
if (s.ok()) {
sub_compact.actual_start = std::move(result.actual_start);
......@@ -2122,9 +2131,9 @@ Status CompactionJob::FinishCompactionOutputFile(
DecodeFixed64(tp.user_collected_properties
.find(TablePropertiesNames::kLatestTimeEndCompact)
->second.c_str());
ROCKS_LOG_INFO(db_options_.info_log, "ratio:%" PRIu64 ", scan:%" PRIu64,
meta->prop.ratio_expire_time,
meta->prop.scan_gap_expire_time);
ROCKS_LOG_INFO(
db_options_.info_log, "fcof: ratio:%" PRIu64 ", scan:%" PRIu64,
meta->prop.ratio_expire_time, meta->prop.scan_gap_expire_time);
}
}
......
......@@ -893,17 +893,17 @@ void DBImpl::ScheduleTtlGC() {
LogBuffer log_buffer_debug(InfoLogLevel::DEBUG_LEVEL,
immutable_db_options_.info_log.get());
auto should_marked_for_compacted = [&](uint64_t file_number,
auto should_marked_for_compacted = [&](int level, uint64_t file_number,
uint64_t ratio_expire_time,
uint64_t scan_gap_expire_time,
uint64_t now) {
bool should_mark = std::min(ratio_expire_time, scan_gap_expire_time) <= now;
if (should_mark) {
ROCKS_LOG_BUFFER(&log_buffer_info,
"SST Table property id = %" PRIu64 ", info : (%" PRIu64
" , %" PRIu64 ") now = %" PRIu64,
file_number, ratio_expire_time, scan_gap_expire_time,
now);
"SST Table property level=%d file-id = %" PRIu64
", info : (%" PRIu64 " , %" PRIu64 ") now = %" PRIu64,
level, file_number, ratio_expire_time,
scan_gap_expire_time, now);
}
return should_mark;
};
......@@ -920,20 +920,21 @@ void DBImpl::ScheduleTtlGC() {
VersionStorageInfo* vstorage = cfd->current()->storage_info();
for (int l = 0; l < vstorage->num_non_empty_levels(); l++) {
for (auto meta : vstorage->LevelFiles(l)) {
++total_cnt;
mark_count += meta->marked_for_compaction;
if (meta->being_compacted) {
continue;
}
++total_cnt;
marked_count += meta->marked_for_compaction;
TEST_SYNC_POINT("DBImpl:Exist-SST");
if (!meta->marked_for_compaction &&
should_marked_for_compacted(
meta->fd.GetNumber(), meta->prop.ratio_expire_time,
l, meta->fd.GetNumber(), meta->prop.ratio_expire_time,
meta->prop.scan_gap_expire_time, nowSeconds)) {
meta->marked_for_compaction = true;
vstorage->AddFilesMarkedForCompaction(l, meta);
}
if (meta->marked_for_compaction) {
mark_count++;
TEST_SYNC_POINT("DBImpl:ScheduleTtlGC-mark");
}
}
......
......@@ -384,6 +384,13 @@ Status FlushJob::WriteLevel0Table() {
TableFileCreationReason::kFlush, event_logger_, job_context_->job_id,
Env::IO_HIGH, &table_properties_, 0 /* level */, flush_load_,
current_time, oldest_key_time, write_hint);
if (cfd_->ioptions()->ttl_extractor_factory != nullptr) {
ROCKS_LOG_INFO(db_options_.info_log,
"Flush: ratio:%" PRIu64 ", scan:%" PRIu64,
meta_[0].prop.ratio_expire_time,
meta_[0].prop.scan_gap_expire_time);
}
LogFlush(db_options_.info_log);
}
ROCKS_LOG_INFO(db_options_.info_log,
......
......@@ -1814,7 +1814,12 @@ void VersionStorageInfo::ComputeFilesMarkedForCompaction() {
void VersionStorageInfo::AddFilesMarkedForCompaction(int level,
FileMetaData* meta) {
files_marked_for_compaction_.emplace_back(level, meta);
if (level < num_non_empty_levels_ - 1) {
files_marked_for_compaction_.emplace_back(level, meta);
} else {
assert(level == num_non_empty_levels_ - 1);
bottommost_files_marked_for_compaction_.emplace_back(level, meta);
}
}
void VersionStorageInfo::ComputeExpiredTtlFiles(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册