Skip to content

Commit

Permalink
fix potential endless loop in merge
Browse files Browse the repository at this point in the history
avoid single segments lists without deletes as merge candidates, as they will be moved
to a merge operation and filtered for merging in the next
consider_merge_options call. In rare cases this may end up in a endless
merge loop where only single segments where nothing is to be done are
merged.
  • Loading branch information
PSeitz committed Jul 24, 2024
1 parent 7ebcc15 commit 0321e8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/indexer/segment_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,13 @@ impl SegmentUpdater {
}

fn consider_merge_options(&self) {
let (committed_segments, uncommitted_segments) = self.get_mergeable_segments();
let (mut committed_segments, mut uncommitted_segments) = self.get_mergeable_segments();
if committed_segments.len() == 1 && committed_segments[0].num_deleted_docs() == 0 {
committed_segments.clear();
}
if uncommitted_segments.len() == 1 && uncommitted_segments[0].num_deleted_docs() == 0 {
uncommitted_segments.clear();
}

// Committed segments cannot be merged with uncommitted_segments.
// We therefore consider merges using these two sets of segments independently.
Expand Down

0 comments on commit 0321e8c

Please sign in to comment.