Skip to content

Force merge with only_expunge_deletes should honor max segment size #7644

@msfroh

Description

@msfroh

Is your feature request related to a problem? Please describe.
There is longstanding logic that ignores the max segment size when doing any kind of forced merge, here https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/index/OpenSearchTieredMergePolicy.java#L59.

This makes sense when you have an index that stops receiving updates, has been switched to read-only, and you want to merge down to a single segment.

There are times, though, when someone just wants to periodically expunge deletes, because soft deletes mean that they have accumulated way too many deleted docs. As mentioned in e.g. the answer to this Stackoverflow question, this may result in segments that are larger than the max segment size, so they will never merge away deletes going forward (unless there are so many deletes that the segment could drop back below the max segment size).

Describe the solution you'd like
I would like a force merge with only_expunge_deletes to honor the max segment size.

The simple way to do that is to change this line to use regularMergePolicy instead of forcedMergePolicy.

Describe alternatives you've considered
I guess we could add another option to the force merge API to say "merge away deletes, but still honor the max segment size" (or even just add a general "honor the max segment size" argument).

In my opinion, only_expunge_deletes already implies that I just want to get rid of deletes and am not trying to merge to one big segment.

Additional context
N/A

Metadata

Metadata

Assignees

Labels

IndexingIndexing, Bulk Indexing and anything related to indexingenhancementEnhancement or improvement to existing feature or requestv2.12.0Issues and PRs related to version 2.12.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions