-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Resolve indices using original index pattern #134218
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
String q = "FROM nomatch*,cluster-a:nomatch"; | ||
String expectedError = "Unknown index [cluster-a:nomatch,nomatch*]"; | ||
String expectedError = "Unknown index [nomatch*,cluster-a:nomatch]"; | ||
expectVerificationExceptionForQuery(q, expectedError, requestIncludeMeta); |
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.
Here and in 3 below cases the error message index now matches the original input (notice that the order was different).
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.
Is this ordering stable - i.e. is it going to always match original order, no matter how many patterns and clusters we have?
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.
Correct, error uses indexPattern
. We are supplying original user input into it now.
assertThat(e.getMessage(), containsString(LICENSE_ERROR_MESSAGE)); | ||
} | ||
|
||
@AwaitsFix(bugUrl = "es-12487") |
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.
It is an interesting issue.
This test verifies index resolution with something like FROM fake-remote:events
.
Field caps relies on returnLocalAll = true
at
Lines 171 to 172 in 18286be
final Map<String, OriginalIndices> remoteClusterIndices = transportService.getRemoteClusterService() | |
.groupIndices(request.indicesOptions(), request.indices()); |
that causes it to return all indices from local clusters when all remotes are not found.
There are existing issues about it: #115262 and #115872
Today this flag is not exposed via FieldCapabilitiesRequest
so I am not sure how this could be fixed.
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.
Depends on #134284
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java
VerificationException.class, | ||
containsString("Unknown index [xremote*:events]"), | ||
() -> runQuery("FROM xremote*:events | STATS count(*)", requestIncludeMeta).close() | ||
); |
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.
Prior behavior returned empty result for empty index resolution.
Now this is complaining about empty index resolution (consistent with FROM empty-pattern-*
case)
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java
assertEquals(400, e.getResponse().getStatusLine().getStatusCode()); | ||
assertThat(e.getMessage(), containsString("verification_exception")); | ||
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo]"), containsString("Unknown index [remote_cluster:foo]"))); | ||
assertThat(e.getMessage(), anyOf(containsString("Unknown index [foo]"), containsString("Unknown index [*:foo]"))); |
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 randomly query foo
or *:foo
. Prior message was actually resolving *
to all known remotes. I do not think this is desired behavior.
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.
Okay, we need to keep old resolved remote_cluster:foo
in case old cluster is coordinating the query.
I will check if we can make this check version dependent.
); | ||
Set<String> expectedUnknownIndexes = org.elasticsearch.common.Strings.commaDelimitedListToSet(expectedIndexExpressionInError); | ||
assertThat(actualUnknownIndexes, equalTo(expectedUnknownIndexes)); | ||
assertThat(error.getMessage(), containsString("Unknown index [" + index + "]")); |
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.
Match original query pattern, not semi resolved pattern
Pinging @elastic/es-analytical-engine (Team:Analytics) |
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/PreAnalyzer.java
if (preAnalysis.indexPattern() != null) { | ||
String indexExpressionToResolve = EsqlCCSUtils.createIndexExpressionFromAvailableClusters(executionInfo); | ||
if (indexExpressionToResolve.isEmpty()) { | ||
if (executionInfo.clusterAliases().isEmpty()) { |
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 think we're back to the same question of whether this is right or not when we call it the second time. Is this intentional to have it here, or it's just sneaked in from merging the previous patch?
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.
Related to #135353 (comment)
OK, I see! But we are calling preAnalyzeMainIndices twice - once at the beginning (now) and once if the filtered analysis fails. Is that also true for the second invocation? In any case, I'd add a comment to it - with this change, the existing comment is no longer true, and would be just confusing.
There are several aspects to this question:
- today this behaves different from local only resolution: local does not allow empty resolution. We would like to change it to alight with DSL behavior. Once that is done this check should actually go away.
- with respect for retrying analysis without filter: this would retry the same expression (even if some clusters should be skipped resulting in duplicated connection errors). I feel like this falls into ES-12978 issue category. With flat expression it is very tricky to manipulate input to exclude those clusters. Since we are going to be restarting analysis from scratch I would rather clear errors and start analysis fresh with no filter.
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.
All considered, IMHO this seems reasonable.
I feel like this falls into ES-12978
ES-12978 is for CPS, but I guess we have the same problem with CCS now.
My assumption is that we'll address this problem before 9.3 FF.
Since we are going to be restarting analysis from scratch I would rather clear errors and start analysis fresh
++
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 think this is good, as long as we agree on the point raised by Stas (ie. ES-12978)
if (preAnalysis.indexPattern() != null) { | ||
String indexExpressionToResolve = EsqlCCSUtils.createIndexExpressionFromAvailableClusters(executionInfo); | ||
if (indexExpressionToResolve.isEmpty()) { | ||
if (executionInfo.clusterAliases().isEmpty()) { |
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.
All considered, IMHO this seems reasonable.
I feel like this falls into ES-12978
ES-12978 is for CPS, but I guess we have the same problem with CCS now.
My assumption is that we'll address this problem before 9.3 FF.
Since we are going to be restarting analysis from scratch I would rather clear errors and start analysis fresh
++
Replaced with #136009 |
Today we parse original index pattern into
EsqlExecutionInfo#clusterInfo
and then assemble it backcreateIndexExpressionFromAvailableClusters
.In CPS with flat expressions resolution logic is more complex and should be delegated to field caps call using original expression.