Skip to content

Commit 31eb76b

Browse files
authored
Fix ingestion level selection (#395)
Signed-off-by: Yang Zhang <[email protected]>
1 parent 42687d1 commit 31eb76b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

db/external_sst_file_ingestion_job.cc

+8-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// COPYING file in the root directory) and Apache 2.0 License
44
// (found in the LICENSE.Apache file in the root directory).
55

6-
76
#include "db/external_sst_file_ingestion_job.h"
87

98
#include <algorithm>
@@ -912,16 +911,7 @@ Status ExternalSstFileIngestionJob::AssignLevelAndSeqnoForIngestedFile(
912911
if (lvl > 0 && lvl < vstorage->base_level()) {
913912
continue;
914913
}
915-
if (cfd_->RangeOverlapWithCompaction(
916-
file_to_ingest->smallest_internal_key.user_key(),
917-
file_to_ingest->largest_internal_key.user_key(), lvl)) {
918-
// We must use L0 or any level higher than `lvl` to be able to overwrite
919-
// the compaction output keys that we overlap with in this level, We also
920-
// need to assign this file a seqno to overwrite the compaction output
921-
// keys in level `lvl`
922-
overlap_with_db = true;
923-
break;
924-
} else if (vstorage->NumLevelFiles(lvl) > 0) {
914+
if (vstorage->NumLevelFiles(lvl) > 0) {
925915
bool overlap_with_level = false;
926916
status = sv->current->OverlapWithLevelIterator(
927917
ro, env_options_, file_to_ingest->smallest_internal_key.user_key(),
@@ -1123,6 +1113,13 @@ bool ExternalSstFileIngestionJob::IngestedFileFitInLevel(
11231113
return false;
11241114
}
11251115

1116+
if (cfd_->RangeOverlapWithCompaction(file_smallest_user_key,
1117+
file_largest_user_key, level)) {
1118+
// File overlap with a running compaction output that will be stored
1119+
// in this level, we cannot add this file to this level
1120+
return false;
1121+
}
1122+
11261123
// File did not overlap with level files, nor compaction output
11271124
return true;
11281125
}

0 commit comments

Comments
 (0)