Add minimum compatibility version to SearchRequest#65896
Add minimum compatibility version to SearchRequest#65896astefan merged 15 commits intoelastic:masterfrom
Conversation
to REST. The minimum version helps failing a request if any shards involved in the search do not meet the compatibility requirements (all shards need to have a version equal or later than the minimum version provided).
|
Pinging @elastic/es-search (Team:Search) |
jimczi
left a comment
There was a problem hiding this comment.
I left some comments but the logic looks good to me.
| final SearchActionListener<SearchPhaseResult> listener) { | ||
| ShardSearchRequest request = rewriteShardSearchRequest(super.buildShardSearchRequest(shardIt)); | ||
| getSearchTransport().sendExecuteQuery(getConnection(shard.getClusterAlias(), shard.getNodeId()), request, getTask(), listener); | ||
| Transport.Connection conn = getConnection(shard.getClusterAlias(), shard.getNodeId()); |
There was a problem hiding this comment.
Can you move this to AbstractSearchAsyncAction#getConnection ? There's nothing that prevents to check the version there.
| ShardSearchRequest request = rewriteShardSearchRequest(super.buildShardSearchRequest(shardIt)); | ||
| getSearchTransport().sendExecuteQuery(getConnection(shard.getClusterAlias(), shard.getNodeId()), request, getTask(), listener); | ||
| Transport.Connection conn = getConnection(shard.getClusterAlias(), shard.getNodeId()); | ||
| if (minVersion != null && conn.getVersion().before(minVersion)) { |
There was a problem hiding this comment.
conn can be null too so you'll need to handle this case.
| finalReduce = true; | ||
| } | ||
| ccsMinimizeRoundtrips = in.readBoolean(); | ||
| if (in.getVersion().onOrAfter(Version.V_7_11_0)) { |
There was a problem hiding this comment.
You need to start with 8.0.0 and adapt the checks after the backport
| } | ||
| out.writeBoolean(ccsMinimizeRoundtrips); | ||
|
|
||
| if (out.getVersion().onOrAfter(Version.V_7_11_0)) { |
| throw new SearchPhaseExecutionException(getName(), msg, null, ShardSearchFailure.EMPTY_ARRAY); | ||
| } | ||
| } | ||
| if (checkMinimumVersion(shardsIts) == false) { |
There was a problem hiding this comment.
You don't need to check the minimum version if it's equal to the minimum compatible version (default value).
| org.elasticsearch.action.search.VersionMismatchException.class, | ||
| org.elasticsearch.action.search.VersionMismatchException::new, | ||
| 161, | ||
| Version.V_7_11_0); |
There was a problem hiding this comment.
For now it's just a 8.0.0 exception, you'll need to adapt the version after the backport
| return new SearchRequest(originalSearchRequest, indices, clusterAlias, absoluteStartMillis, finalReduce); | ||
| } | ||
|
|
||
| public static SearchRequest withMinimumVersion(SearchRequest searchRequest, Version minVersion) { |
There was a problem hiding this comment.
You could reuse the subSearchRequest above and just add a nullable minCompatibleShardNode argument ? That makes sense to me because we need to set ccsMinimizeRoundtrips to false there too and these sub search requests are meant for internal use (using the transport client only).
Should we add also a check that the min version is greater or equals than the minimum compatibility version ?
There was a problem hiding this comment.
We should also ensure that ccsMinimizeRoundtrips is set to false, otherwise the check will not be applied on the remote cluster. We can force the value here searchRequest.cssMinimizeRountrips(false) but we should also verify the final value in SearchRequest#validate.
| @@ -319,6 +336,9 @@ long getAbsoluteStartMillis() { | |||
| return absoluteStartMillis; | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
Maybe rename to something more explicit: minCompatibleShardNode ?
jimczi
left a comment
There was a problem hiding this comment.
The change looks great. Thanks for adding the mixed cluster tests. I left one comment regarding the ccs_minimize_roundtrips that could be unset automatically.
| @@ -97,6 +97,9 @@ public class SearchRequest extends ActionRequest implements IndicesRequest.Repla | |||
|
|
|||
| private boolean ccsMinimizeRoundtrips = true; | |||
There was a problem hiding this comment.
Should we switch to a Boolean with a default value of null ? This way we can decide the default value depending on whether the minCompatibleShardNode is set or not ? It feels wrong that you have to explicitly disable this option when using minCompatibleShardNode. It should be done automatically unless the user sets the ccsMinimizeRoundtrips value explicitly.
There was a problem hiding this comment.
@jimczi I've made the change, but slightly different from your suggestion as it wasn't easy to enforce a certain value for ccsMinimizeRoundtrips in all cases. Thus, I've removed the setter and kept as the sole option of setting minCompatibleShardNode for a search request - a constructor (which will also set ccsMinimizeRoundtrips).
use 8.0.0 as the version to test against.
* Adds a minimum version request parameter to SearchRequest. The minimum version helps failing a request if any shards involved in the search do not meet the compatibility requirements (all shards need to have a version equal or later than the minimum version provided). (cherry picked from commit e3386e1)
Adds a minimum version request parameter to SearchRequest. The minimum version helps failing a request if any shards involved in the search do not meet the compatibility requirements (all shards need to have a version equal or later than the minimum version provided).
Relates to #63304.