-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Force Merge should reject requests with
only_expunge_deletes
and `m…
…ax_num_segments` set (#44761) This commit changes the ForceMergeRequest.validate() method so that it does not accept the parameters only_expunge_deletes and max_num_segments to be set at the same time. The motivation is that InternalEngine.forceMerge() just ignores the max. number of segments parameter when the only expunge parameter is set to true, leaving the wrong impression to the user that max. number of segments has been applied. It also changes InternalEngine.forceMerge() so that it now throws an exception when both parameters are set, and modifies tests where needed. Because it changes the behavior of the REST API I marked this as >breaking. Closes #43102
- Loading branch information
Showing
8 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[float] | ||
[[breaking_80_indices_changes]] | ||
=== Force Merge API changes | ||
|
||
Previously, the Force Merge API allowed the parameters `only_expunge_deletes` | ||
and `max_num_segments` to be set to a non default value at the same time. But | ||
the `max_num_segments` was silently ignored when `only_expunge_deletes` is set | ||
to `true`, leaving the false impression that it has been applied. | ||
|
||
The Force Merge API now rejects requests that have a `max_num_segments` greater | ||
than or equal to 0 when the `only_expunge_deletes` is set to true. |
This file contains 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
This file contains 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
This file contains 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
54 changes: 54 additions & 0 deletions
54
...c/test/java/org/elasticsearch/action/admin/indices/forcemerge/ForceMergeRequestTests.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.action.admin.indices.forcemerge; | ||
|
||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import static org.hamcrest.Matchers.contains; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
public class ForceMergeRequestTests extends ESTestCase { | ||
|
||
public void testValidate() { | ||
final boolean flush = randomBoolean(); | ||
final boolean onlyExpungeDeletes = randomBoolean(); | ||
final int maxNumSegments = randomIntBetween(ForceMergeRequest.Defaults.MAX_NUM_SEGMENTS, 100); | ||
|
||
final ForceMergeRequest request = new ForceMergeRequest(); | ||
request.flush(flush); | ||
request.onlyExpungeDeletes(onlyExpungeDeletes); | ||
request.maxNumSegments(maxNumSegments); | ||
|
||
assertThat(request.flush(), equalTo(flush)); | ||
assertThat(request.onlyExpungeDeletes(), equalTo(onlyExpungeDeletes)); | ||
assertThat(request.maxNumSegments(), equalTo(maxNumSegments)); | ||
|
||
ActionRequestValidationException validation = request.validate(); | ||
if (onlyExpungeDeletes && maxNumSegments != ForceMergeRequest.Defaults.MAX_NUM_SEGMENTS) { | ||
assertThat(validation, notNullValue()); | ||
assertThat(validation.validationErrors(), contains("cannot set only_expunge_deletes and max_num_segments at the " | ||
+ "same time, those two parameters are mutually exclusive")); | ||
} else { | ||
assertThat(validation, nullValue()); | ||
} | ||
} | ||
} |
This file contains 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