Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ private E delete(Object key) {

public Set<String> attributeNames() {
Set<String> s = Sets.newLinkedHashSetWithExpectedSize(size());

for (AttributeWrapper aw : delegate.keySet()) {
s.add(aw.attr.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ public void analyzedPlan(
.<PreAnalysisResult>andThenApply(enrichResolution -> FieldNameUtils.resolveFieldNames(parsed, enrichResolution))
.<PreAnalysisResult>andThen((l, r) -> resolveInferences(parsed, r, l))
.<PreAnalysisResult>andThen((l, r) -> preAnalyzeMainIndices(preAnalysis, executionInfo, r, requestFilter, l))
.andThenApply(r -> {
if (r.indices.isValid()
&& executionInfo.isCrossClusterSearch()
&& executionInfo.getRunningClusterAliases().findAny().isEmpty()) {
LOGGER.debug("No more clusters to search, ending analysis stage");
throw new NoClustersToSearchException();
}
return r;
})
.<PreAnalysisResult>andThen((l, r) -> preAnalyzeLookupIndices(preAnalysis.lookupIndices().iterator(), r, executionInfo, l))
.<LogicalPlan>andThen((l, r) -> analyzeWithRetry(parsed, requestFilter, preAnalysis, executionInfo, r, l))
.addListener(logicalPlanListener);
Expand Down Expand Up @@ -657,7 +666,8 @@ private void preAnalyzeMainIndices(
default -> requestFilter;
},
preAnalysis.indexMode() == IndexMode.TIME_SERIES,
listener.delegateFailure((l, indexResolution) -> {
listener.delegateFailureAndWrap((l, indexResolution) -> {
EsqlCCSUtils.updateExecutionInfoWithUnavailableClusters(executionInfo, indexResolution.failures());
l.onResponse(result.withIndexResolution(indexResolution));
})
);
Expand All @@ -676,21 +686,8 @@ private void analyzeWithRetry(
PreAnalysisResult result,
ActionListener<LogicalPlan> listener
) {
if (result.indices.isValid()) {
EsqlCCSUtils.updateExecutionInfoWithUnavailableClusters(executionInfo, result.indices.failures());
if (executionInfo.isCrossClusterSearch()
&& executionInfo.getClusterStates(EsqlExecutionInfo.Cluster.Status.RUNNING).findAny().isEmpty()) {
// for a CCS, if all clusters have been marked as SKIPPED, nothing to search so send a sentinel Exception
// to let the LogicalPlanActionListener decide how to proceed
LOGGER.debug("No more clusters to search, ending analysis stage");
listener.onFailure(new NoClustersToSearchException());
return;
}
}

var description = requestFilter == null ? "the only attempt without filter" : "first attempt with filter";
LOGGER.debug("Analyzing the plan ({})", description);

try {
if (result.indices.isValid() || requestFilter != null) {
// We won't run this check with no filter and no valid indices since this may lead to false positive - missing index report
Expand All @@ -715,7 +712,6 @@ private void analyzeWithRetry(
try {
// the order here is tricky - if the cluster has been filtered and later became unavailable,
// do we want to declare it successful or skipped? For now, unavailability takes precedence.
EsqlCCSUtils.updateExecutionInfoWithUnavailableClusters(executionInfo, r.indices.failures());
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, r.indices, false);
LogicalPlan plan = analyzedPlan(parsed, r, executionInfo);
LOGGER.debug("Analyzed plan (second attempt without filter):\n{}", plan);
Expand Down