Skip to content

Commit

Permalink
Honor max segment size during only_expunge_deletes (opensearch-projec…
Browse files Browse the repository at this point in the history
…t#10036)

(cherry picked from commit 1dde018)
Signed-off-by: Michael Froh <froh@amazon.com>
  • Loading branch information
msfroh committed Oct 18, 2023
1 parent 3763207 commit d84c5c7
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 @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bump `org.bouncycastle:bc-fips` from 1.0.2.3 to 1.0.2.4 ([#10297](https://github.com/opensearch-project/OpenSearch/pull/10297))

### Changed
- Force merge with `only_expunge_deletes` honors max segment size ([#10036](https://github.com/opensearch-project/OpenSearch/pull/10036))
- Add the means to extract the contextual properties from HttpChannel, TcpCChannel and TrasportChannel without excessive typecasting ([#10562](https://github.com/opensearch-project/OpenSearch/pull/10562))
- Backport the PR #9107 for updating CONCURRENT_SEGMENT_SEARCH_TARGET_MAX_SLICE_COUNT_KEY setting to a dynamic setting ([#10606](https://github.com/opensearch-project/OpenSearch/pull/10606))
- [Remote Store] Add Remote Store backpressure rejection stats to `_nodes/stats` ([#10524](https://github.com/opensearch-project/OpenSearch/pull/10524))
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 d84c5c7

Please sign in to comment.