Skip to content

Commit

Permalink
Honor max segment size during only_expunge_deletes (#10036)
Browse files Browse the repository at this point in the history
  • Loading branch information
msfroh authored Sep 23, 2023
1 parent 9e90671 commit 1dde018
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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() {
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);
}
}

0 comments on commit 1dde018

Please sign in to comment.