-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix test fail on unavailable shards resolver #125096
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
Changes from 2 commits
07be3f2
ce2b86a
56fb6ce
d185356
eec7176
aea8859
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,7 +482,13 @@ private void preAnalyzeIndices( | |
| indexExpressionToResolve, | ||
| result.fieldNames, | ||
| requestFilter, | ||
| listener.map(indexResolution -> result.withIndexResolution(indexResolution)) | ||
| listener.delegateFailure((l, indexResolution) -> { | ||
| if (configuration.allowPartialResults() == false && indexResolution.getLocalResolutionFailure() != null) { | ||
| l.onFailure(indexResolution.getLocalResolutionFailure().getException()); | ||
| } else { | ||
| l.onResponse(result.withIndexResolution(indexResolution)); | ||
| } | ||
| }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change completes the listener early, immediately after index resolution with a failure if there are failures |
||
| ); | ||
| } | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| */ | ||
| package org.elasticsearch.xpack.esql.session; | ||
|
|
||
| import org.elasticsearch.ExceptionsHelper; | ||
| import org.elasticsearch.action.ActionListener; | ||
| import org.elasticsearch.action.fieldcaps.FieldCapabilitiesFailure; | ||
| import org.elasticsearch.action.fieldcaps.FieldCapabilitiesIndexResponse; | ||
|
|
@@ -87,7 +88,10 @@ public void resolveAsMergedMapping( | |
| client.execute( | ||
| EsqlResolveFieldsAction.TYPE, | ||
| createFieldCapsRequest(indexWildcard, fieldNames, requestFilter), | ||
| listener.delegateFailureAndWrap((l, response) -> l.onResponse(mergedMappings(indexWildcard, response))) | ||
| listener.delegateFailureAndWrap((l, response) -> { | ||
|
|
||
| l.onResponse(mergedMappings(indexWildcard, response)); | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -152,6 +156,14 @@ public static IndexResolution mergedMappings(String indexPattern, FieldCapabilit | |
| fieldCapsResponse.getFailures() | ||
| ); | ||
|
|
||
| FieldCapabilitiesFailure localResolutionFailure = null; | ||
| for (FieldCapabilitiesFailure failure : fieldCapsResponse.getFailures()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can mistakenly use failures from the remote clusters. Can we extend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are right. I have replaced this with filtering for |
||
| if (ExceptionsHelper.isRemoteUnavailableException(failure.getException()) == false) { | ||
| localResolutionFailure = failure; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| Map<String, IndexMode> concreteIndices = Maps.newMapWithExpectedSize(fieldCapsResponse.getIndexResponses().size()); | ||
| for (FieldCapabilitiesIndexResponse ir : fieldCapsResponse.getIndexResponses()) { | ||
| concreteIndices.put(ir.getIndexName(), ir.getIndexMode()); | ||
|
|
@@ -163,7 +175,7 @@ public static IndexResolution mergedMappings(String indexPattern, FieldCapabilit | |
| } | ||
| // If all the mappings are empty we return an empty set of resolved indices to line up with QL | ||
| var index = new EsIndex(indexPattern, rootFields, allEmpty ? Map.of() : concreteIndices, partiallyUnmappedFields); | ||
| return IndexResolution.valid(index, concreteIndices.keySet(), unavailableRemotes); | ||
| return IndexResolution.valid(index, concreteIndices.keySet(), localResolutionFailure, unavailableRemotes); | ||
| } | ||
|
|
||
| private static Map<String, List<IndexFieldCapabilities>> collectFieldCaps(FieldCapabilitiesResponse fieldCapsResponse) { | ||
|
|
||
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 we merge this with
unavailableClusters?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 do not think so. I just updated the implementation to look for unavailable shards rather than generic failures and I would like to keep
unavailableClustersremote only as documented:elasticsearch/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/index/IndexResolution.java
Line 63 in d185356