Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion db/db_impl/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,14 @@ Status DBImpl::CompactRangeInternal(const CompactRangeOptions& options,
check_overlap_within_file = false;
}
}
if (!check_overlap_within_file) {
// `check_range_overlap_on_bottom_level` set to true means we check SST
// range overlap instead of real kv overlap to ensure that Manual
// Compact can be trigger on the overlapped SST files, so the SST files
// with big range can be split by the CompactionPartitioner.
if (!check_overlap_within_file ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why !check_overlap_within_file is not sufficient?

if (!partitioner->CanDoTrivialMove(*begin, *end)) {
check_overlap_within_file = false;
}

Seems that if there are partitioner boundaries within the target range, it will trigger a compaction, not trivial move (by setting overlap to the current level)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, it's better to just change the CanDoTrivialMove implement in the SSTPartitioner. No need to add a new option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it seems CanDoTrivialMove can't tell whether we are at the bottommost level? It only sees the key range

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I think we should force partition/manual compact the overlapped SST files in all the level, not only the bottom level. This approach should gain better compatibility. So reuse CanDoTrivialMove is enough here.

(!overlap && options.check_range_overlap_on_bottom_level &&
level ==
current_version->storage_info()->num_non_empty_levels() - 1)) {
overlap = current_version->storage_info()->OverlapInLevel(level,
begin, end);
}
Expand Down
10 changes: 10 additions & 0 deletions db/external_sst_file_ingestion_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,9 @@ Status ExternalSstFileIngestionJob::AssignLevelAndSeqnoForIngestedFile(
// the keys that we overlap with in this level, We also need to assign
// this file a seqno to overwrite the existing keys in level `lvl`
overlap_with_db = true;
ROCKS_LOG_INFO(db_options_.info_log,
"Ingest file overlap with level %d, file: %s", lvl,
file_to_ingest->internal_file_path.c_str());
break;
}

Expand Down Expand Up @@ -1110,13 +1113,20 @@ bool ExternalSstFileIngestionJob::IngestedFileFitInLevel(
&file_largest_user_key)) {
// File overlap with another files in this level, we cannot
// add it to this level
ROCKS_LOG_INFO(
db_options_.info_log,
"Ingest file overlap with level file range, level %d, ingset_file: %s",
level, file_to_ingest->internal_file_path.c_str());
return false;
}

if (cfd_->RangeOverlapWithCompaction(file_smallest_user_key,
file_largest_user_key, level)) {
// File overlap with a running compaction output that will be stored
// in this level, we cannot add this file to this level
ROCKS_LOG_INFO(db_options_.info_log,
"Ingest file overlap with compaction in level %d, file: %s",
level, file_to_ingest->internal_file_path.c_str());
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions include/rocksdb/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,11 @@ struct CompactRangeOptions {
// user-provided setting. This enables customers to selectively override the
// age cutoff.
double blob_garbage_collection_age_cutoff = -1;

// If set to true, it will check file range overlap instead of keys overlap
// for the bottom level. This is used in manual compact for SST ingestion
// scenario.
bool check_range_overlap_on_bottom_level = false;
};

// IngestExternalFileOptions is used by IngestExternalFile()
Expand Down