- 
                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 5 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -7,6 +7,7 @@ | |
| package org.elasticsearch.xpack.esql.session; | ||
| 
     | 
||
| import org.elasticsearch.action.ActionListener; | ||
| import org.elasticsearch.action.NoShardAvailableActionException; | ||
| import org.elasticsearch.action.fieldcaps.FieldCapabilitiesFailure; | ||
| import org.elasticsearch.action.fieldcaps.FieldCapabilitiesIndexResponse; | ||
| import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; | ||
| 
          
            
          
           | 
    @@ -152,6 +153,13 @@ public static IndexResolution mergedMappings(String indexPattern, FieldCapabilit | |
| fieldCapsResponse.getFailures() | ||
| ); | ||
| 
     | 
||
| Set<NoShardAvailableActionException> unavailableShards = new HashSet<>(); | ||
| 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 (failure.getException() instanceof NoShardAvailableActionException e) { | ||
| 
         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 is restrictive and could be fragile. The field-caps API can fail for reasons other than a NoShardAvailableActionException. Should we handle all exceptions? I'm fine if you plan to address this in a follow-up. 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 case is happening when running  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 we should detect the index pattern for non-remote scenarios and handle all exceptions.  | 
||
| unavailableShards.add(e); | ||
| } | ||
| } | ||
| 
     | 
||
| Map<String, IndexMode> concreteIndices = Maps.newMapWithExpectedSize(fieldCapsResponse.getIndexResponses().size()); | ||
| for (FieldCapabilitiesIndexResponse ir : fieldCapsResponse.getIndexResponses()) { | ||
| concreteIndices.put(ir.getIndexName(), ir.getIndexMode()); | ||
| 
        
          
        
         | 
    @@ -163,7 +171,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(), unavailableShards, 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.
This change completes the listener early, immediately after index resolution with a failure if there are failures