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

Honor max segment size during only_expunge_deletes #10036

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add instrumentation in rest and network layer. ([#9415](https://github.com/opensearch-project/OpenSearch/pull/9415))
- Allow parameterization of tests with OpenSearchIntegTestCase.SuiteScopeTestCase annotation ([#9916](https://github.com/opensearch-project/OpenSearch/pull/9916))
- Mute the query profile IT with concurrent execution ([#9840](https://github.com/opensearch-project/OpenSearch/pull/9840))
- Force merge with `only_expunge_deletes` honors max segment size ([#10036](https://github.com/opensearch-project/OpenSearch/pull/10036))
- Add instrumentation in transport service. ([#10042](https://github.com/opensearch-project/OpenSearch/pull/10042))

### Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

/**
* Wrapper around {@link TieredMergePolicy} which doesn't respect
* {@link TieredMergePolicy#setMaxMergedSegmentMB(double)} on forced merges.
* {@link TieredMergePolicy#setMaxMergedSegmentMB(double)} on forced merges, but DOES respect it on only_expunge_deletes.
* See https://issues.apache.org/jira/browse/LUCENE-7976.
*
* @opensearch.internal
Expand Down Expand Up @@ -71,7 +71,7 @@ public MergeSpecification findForcedMerges(

@Override
public MergeSpecification findForcedDeletesMerges(SegmentInfos infos, MergeContext mergeContext) throws IOException {
return forcedMergePolicy.findForcedDeletesMerges(infos, mergeContext);
return regularMergePolicy.findForcedDeletesMerges(infos, mergeContext);
}

public void setForceMergeDeletesPctAllowed(double forceMergeDeletesPctAllowed) {
Expand All @@ -80,7 +80,7 @@ public void setForceMergeDeletesPctAllowed(double forceMergeDeletesPctAllowed) {
}

public double getForceMergeDeletesPctAllowed() {
reta marked this conversation as resolved.
Show resolved Hide resolved
return forcedMergePolicy.getForceMergeDeletesPctAllowed();
return regularMergePolicy.getForceMergeDeletesPctAllowed();
}

public void setFloorSegmentMB(double mbFrac) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@

package org.opensearch.index;

import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.SegmentCommitInfo;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.util.InfoStream;
import org.apache.lucene.util.Version;
import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;
import java.util.Collections;
import java.util.Set;

public class OpenSearchTieredMergePolicyTests extends OpenSearchTestCase {

public void testDefaults() {
Expand Down Expand Up @@ -80,4 +89,32 @@ public void testSetDeletesPctAllowed() {
policy.setDeletesPctAllowed(42);
assertEquals(42, policy.regularMergePolicy.getDeletesPctAllowed(), 0);
}

public void testFindDeleteMergesReturnsNullOnEmptySegmentInfos() throws IOException {
MergePolicy.MergeSpecification mergeSpecification = new OpenSearchTieredMergePolicy().findForcedDeletesMerges(
new SegmentInfos(Version.LATEST.major),
new MergePolicy.MergeContext() {
@Override
public int numDeletesToMerge(SegmentCommitInfo info) {
return 0;
}

@Override
public int numDeletedDocs(SegmentCommitInfo info) {
return 0;
}

@Override
public InfoStream getInfoStream() {
return InfoStream.NO_OUTPUT;
}

@Override
public Set<SegmentCommitInfo> getMergingSegments() {
return Collections.emptySet();
}
}
);
assertNull(mergeSpecification);
}
}
Loading