Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh after force-merge #76345

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,14 @@ public void forceMerge(final boolean flush, int maxNumSegments, boolean onlyExpu
if (tryRenewSyncCommit() == false) {
flush(false, true);
}

// If any merges happened then we need to release the unmerged input segments so they can be deleted. A periodic refresh
// will do this eventually unless the user has disabled refreshes or isn't searching this shard frequently, in which
// case we should do something here to ensure a timely refresh occurs. However there's no real need to defer it nor to
// have any should-we-actually-refresh-here logic: we're already doing an expensive force-merge operation at the user's
// request and therefore don't expect any further writes so we may as well do the final refresh immediately and get it
// out of the way.
refresh("force-merge");
}
if (upgrade) {
logger.info("finished segment upgrade");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ public void testSegmentsWithMergeFlag() throws Exception {
// now, optimize and wait for merges, see that we have no merge flag
engine.forceMerge(true, 1, false, false, false, UUIDs.randomBase64UUID());

// ensure that we have released the older segments with a refresh so they can be removed
assertFalse(engine.refreshNeeded());

for (Segment segment : engine.segments(false)) {
assertThat(segment.getMergeId(), nullValue());
}
Expand Down