-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add minimum compatibility version to SearchRequest #65896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments but the logic looks good to me.
@@ -80,7 +84,11 @@ protected void executePhaseOnShard(final SearchShardIterator shardIt, | |||
final SearchShardTarget shard, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to AbstractSearchAsyncAction#getConnection
? There's nothing that prevents to check the version there.
@@ -80,7 +84,11 @@ protected void executePhaseOnShard(final SearchShardIterator shardIt, | |||
final SearchShardTarget shard, | |||
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()); | |||
if (minVersion != null && conn.getVersion().before(minVersion)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conn
can be null too so you'll need to handle this case.
@@ -214,6 +226,9 @@ public SearchRequest(StreamInput in) throws IOException { | |||
finalReduce = true; | |||
} | |||
ccsMinimizeRoundtrips = in.readBoolean(); | |||
if (in.getVersion().onOrAfter(Version.V_7_11_0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to start with 8.0.0 and adapt the checks after the backport
@@ -241,7 +256,9 @@ public void writeTo(StreamOutput out) throws IOException { | |||
out.writeBoolean(finalReduce); | |||
} | |||
out.writeBoolean(ccsMinimizeRoundtrips); | |||
|
|||
if (out.getVersion().onOrAfter(Version.V_7_11_0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -210,6 +210,10 @@ public final void run() { | |||
throw new SearchPhaseExecutionException(getName(), msg, null, ShardSearchFailure.EMPTY_ARRAY); | |||
} | |||
} | |||
if (checkMinimumVersion(shardsIts) == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now it's just a 8.0.0 exception, you'll need to adapt the version after the backport
@@ -157,6 +159,16 @@ static SearchRequest subSearchRequest(SearchRequest originalSearchRequest, Strin | |||
return new SearchRequest(originalSearchRequest, indices, clusterAlias, absoluteStartMillis, finalReduce); | |||
} | |||
|
|||
public static SearchRequest withMinimumVersion(SearchRequest searchRequest, Version minVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to something more explicit: minCompatibleShardNode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 @@ | |||
|
|||
private boolean ccsMinimizeRoundtrips = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @astefan!
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.