Skip to content

Commit

Permalink
Remove the min_compatible_shard_node option and associated classes (e…
Browse files Browse the repository at this point in the history
…lastic#114713)

Any similar functionality in the future should use capabilities instead
  • Loading branch information
thecoop authored Oct 16, 2024
1 parent 0fd5839 commit 5faf0cd
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 937 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,6 @@
"description":"Indicates whether hits.total should be rendered as an integer or an object in the rest search response",
"default":false
},
"min_compatible_shard_node":{
"type":"string",
"description":"The minimum compatible version that all shards involved in search should have for this request to be successful"
},
"include_named_queries_score":{
"type": "boolean",
"description":"Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1819,12 +1819,6 @@ private enum ElasticsearchExceptionHandle {
160,
TransportVersions.V_7_10_0
),
VERSION_MISMATCH_EXCEPTION(
org.elasticsearch.action.search.VersionMismatchException.class,
org.elasticsearch.action.search.VersionMismatchException::new,
161,
TransportVersions.V_7_12_0
),
AUTHENTICATION_PROCESSING_ERROR(
org.elasticsearch.ElasticsearchAuthenticationProcessingError.class,
org.elasticsearch.ElasticsearchAuthenticationProcessingError::new,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static TransportVersion def(int id) {
public static final TransportVersion ESQL_PER_AGGREGATE_FILTER = def(8_770_00_0);
public static final TransportVersion ML_INFERENCE_ATTACH_TO_EXISTSING_DEPLOYMENT = def(8_771_00_0);
public static final TransportVersion CONVERT_FAILURE_STORE_OPTIONS_TO_SELECTOR_OPTIONS_INTERNALLY = def(8_772_00_0);
public static final TransportVersion REMOVE_MIN_COMPATIBLE_SHARD_NODE = def(8_773_00_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.NoShardAvailableActionException;
import org.elasticsearch.action.OriginalIndices;
Expand Down Expand Up @@ -234,15 +233,6 @@ public final void run() {
}
if (shardsIts.size() > 0) {
doCheckNoMissingShards(getName(), request, shardsIts);
Version version = request.minCompatibleShardNode();
if (version != null && Version.CURRENT.minimumCompatibilityVersion().equals(version) == false) {
if (checkMinimumVersion(shardsIts) == false) {
throw new VersionMismatchException(
"One of the shards is incompatible with the required minimum version [{}]",
request.minCompatibleShardNode()
);
}
}
for (int i = 0; i < shardsIts.size(); i++) {
final SearchShardIterator shardRoutings = shardsIts.get(i);
assert shardRoutings.skip() == false;
Expand All @@ -260,21 +250,6 @@ void skipShard(SearchShardIterator iterator) {
successfulShardExecution(iterator);
}

private boolean checkMinimumVersion(GroupShardsIterator<SearchShardIterator> shardsIts) {
for (SearchShardIterator it : shardsIts) {
if (it.getTargetNodeIds().isEmpty() == false) {
boolean isCompatible = it.getTargetNodeIds().stream().anyMatch(nodeId -> {
Transport.Connection conn = getConnection(it.getClusterAlias(), nodeId);
return conn == null || conn.getNode().getVersion().onOrAfter(request.minCompatibleShardNode());
});
if (isCompatible == false) {
return false;
}
}
}
return true;
}

private static boolean assertExecuteOnStartThread() {
// Ensure that the current code has the following stacktrace:
// AbstractSearchAsyncAction#start -> AbstractSearchAsyncAction#executePhase -> AbstractSearchAsyncAction#performPhaseOnShard
Expand Down Expand Up @@ -761,12 +736,7 @@ final void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()

@Override
public final Transport.Connection getConnection(String clusterAlias, String nodeId) {
Transport.Connection conn = nodeIdToConnection.apply(clusterAlias, nodeId);
Version minVersion = request.minCompatibleShardNode();
if (minVersion != null && conn != null && conn.getNode().getVersion().before(minVersion)) {
throw new VersionMismatchException("One of the shards is incompatible with the required minimum version [{}]", minVersion);
}
return conn;
return nodeIdToConnection.apply(clusterAlias, nodeId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.common.util.Maps;
Expand Down Expand Up @@ -133,15 +132,6 @@ private static boolean assertSearchCoordinationThread() {
public void run() {
assert assertSearchCoordinationThread();
checkNoMissingShards();
Version version = request.minCompatibleShardNode();
if (version != null && Version.CURRENT.minimumCompatibilityVersion().equals(version) == false) {
if (checkMinimumVersion(shardsIts) == false) {
throw new VersionMismatchException(
"One of the shards is incompatible with the required minimum version [{}]",
request.minCompatibleShardNode()
);
}
}
runCoordinatorRewritePhase();
}

Expand Down Expand Up @@ -378,21 +368,6 @@ public CanMatchNodeRequest.Shard buildShardLevelRequest(SearchShardIterator shar
);
}

private boolean checkMinimumVersion(GroupShardsIterator<SearchShardIterator> shardsIts) {
for (SearchShardIterator it : shardsIts) {
if (it.getTargetNodeIds().isEmpty() == false) {
boolean isCompatible = it.getTargetNodeIds().stream().anyMatch(nodeId -> {
Transport.Connection conn = getConnection(new SendingTarget(it.getClusterAlias(), nodeId));
return conn == null || conn.getNode().getVersion().onOrAfter(request.minCompatibleShardNode());
});
if (isCompatible == false) {
return false;
}
}
}
return true;
}

@Override
public void start() {
if (getNumShards() == 0) {
Expand Down Expand Up @@ -421,12 +396,7 @@ public void onPhaseFailure(String msg, Exception cause) {
}

public Transport.Connection getConnection(SendingTarget sendingTarget) {
Transport.Connection conn = nodeIdToConnection.apply(sendingTarget.clusterAlias, sendingTarget.nodeId);
Version minVersion = request.minCompatibleShardNode();
if (minVersion != null && conn != null && conn.getNode().getVersion().before(minVersion)) {
throw new VersionMismatchException("One of the shards is incompatible with the required minimum version [{}]", minVersion);
}
return conn;
return nodeIdToConnection.apply(sendingTarget.clusterAlias, sendingTarget.nodeId);
}

private int getNumShards() {
Expand Down
Loading

0 comments on commit 5faf0cd

Please sign in to comment.