You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolves #[Issue number to be closed when this PR is merged]
Check List
Functionality includes testing.
API changes companion pull request created, if applicable.
Public documentation issue/PR created, if applicable.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
The multi-format merge path uses NoMergePolicy.INSTANCE as a temporary workaround with a TODO comment indicating it needs to be replaced. This means merges are completely disabled for multi-format setups, which could lead to unbounded segment growth and performance degradation in production if this code path is reached.
} else {
// TODO:: Remove this once the Merge is working for multi format setupmergePolicy = newCompositeMergePolicy(NoMergePolicy.INSTANCE, shardId);
}
The inner switch statement for nodeMergePolicy in the DEFAULT_POLICY branch does not have a default case. If a new IndexMergePolicy enum value is added in the future, mergePolicyProvider could remain null, causing the assertion to fire at runtime. Consider adding a default case with an explicit error or fallback.
The inner switch on nodeMergePolicy has no default case, so if a new IndexMergePolicy enum value is added in the future, mergePolicyProvider will remain null and the subsequent assert will fail at runtime. Adding a default case that throws an IllegalStateException makes the failure explicit and easier to diagnose.
switch (nodeMergePolicy) {
case TIERED:
case DEFAULT_POLICY:
mergePolicyProvider = tieredMergePolicyProvider;
break;
case LOG_BYTE_SIZE:
mergePolicyProvider = logByteSizeMergePolicyProvider;
break;
+ default:+ throw new IllegalStateException("Unsupported node-scoped merge policy: " + nodeMergePolicy);
}
Suggestion importance[1-10]: 6
__
Why: Adding a default case with an explicit exception is a valid defensive programming improvement. Without it, adding a new IndexMergePolicy enum value could leave mergePolicyProvider null, causing the assert to fail with a less informative message. However, the outer switch has the same issue and the assert already provides some safety net.
Low
General
Warn when merging is silently disabled
The NoMergePolicy.INSTANCE path is a temporary workaround that silently disables merging for multi-format setups. This could lead to unbounded segment growth and degraded query performance in production if the TODO is not addressed. Consider throwing an explicit exception or logging a prominent warning to prevent accidental use in production environments.
List<String> secondaryDataFormatNames = indexSettings.getValue(IndexSettings.INDEX_COMPOSITE_SECONDARY_DATA_FORMATS_SETTING);
if(secondaryDataFormatNames.isEmpty()) {
mergePolicy = new CompositeMergePolicy(indexSettings.getMergePolicy(true), shardId);
} else {
// TODO:: Remove this once the Merge is working for multi format setup
+ logger.warn("Merging is disabled for multi-format composite index setup on shard [{}]. Segments will not be merged.", shardId);
mergePolicy = new CompositeMergePolicy(NoMergePolicy.INSTANCE, shardId);
}
Suggestion importance[1-10]: 5
__
Why: Adding a warning log when NoMergePolicy.INSTANCE is used is a reasonable improvement to make the temporary workaround more visible, but it's a minor enhancement since the TODO comment already documents the intent and the code path is intentional.
Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.