-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Set option ignore_unavailable for querying #18146
Conversation
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.
Just two details - the added catch without propagation and the allowNoIndices option introduced together with the ignoreUnavailable.
try { | ||
chunkedResult = multiChunkResultRetriever.retrieveChunkedResult(chunkCommand); | ||
} catch (IllegalArgumentException e) { | ||
LOG.warn("Ignoring invalid scroll request", e); |
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.
Could you please explain why we catch the exception here and don't propagate it further?
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.
Added comment in code.
This allows aggregation or correlation event queries to complete, in the presence of unavailable indices. Ugly, but I don't see where we could add the necessary indicesOptions
in an aggregation query.
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.
@patrickmann - I'm sorry if I am saying stupid things, but I do not understand this one.
MultiChunkResultRetriever
has 4 possible implementations, and you have added options to all 4 of them.
Why is it still throwing exceptions on unavailable indices and requires to handle those surprising exceptions manually?
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 seems that scroll search, when executed on unavailable indices, would not return response with _scroll_id
field.
Because of that construction will fail on this line:
Line 48 in 8132032
checkArgument(initialResult.getScrollId() != null, "Unable to extract scroll id from supplied search result!"); |
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.
@luk-kaminski
You are right - when scroll searching, the exception is thrown from the constructor you mention; not because of a missing ignoreUnavailable
option.
Is there a more elegant way of handling that? I was hesitant to make changes to scroll result processing.
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've committed and pushed a proposal of another method of handling that. Will be grateful for feedback.
@@ -255,7 +254,7 @@ public QueryResult doRun(SearchJob job, Query query, ESGeneratedQueryContext que | |||
return new SearchRequest() | |||
.source(searchTypeQueries.get(searchTypeId)) | |||
.indices(indices.toArray(new String[0])) | |||
.indicesOptions(IndicesOptions.fromOptions(false, false, true, false)); | |||
.indicesOptions(IndicesOptions.fromOptions(true, true, true, false)); |
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.
allowNoIndices is now set to true. Is this by purpose? Does it help with the issue which is solved by this PR?
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.
In case a query contains only invalid indices, we need allowNoIndices
for it to still succeed. This turned up in unit testing.
...ge-elasticsearch7/src/main/java/org/graylog/storage/elasticsearch7/MoreSearchAdapterES7.java
Outdated
Show resolved
Hide resolved
...sticsearch7/src/main/java/org/graylog/storage/elasticsearch7/views/ElasticsearchBackend.java
Outdated
Show resolved
Hide resolved
...-storage-opensearch2/src/main/java/org/graylog/storage/opensearch2/IndexToolsAdapterOS2.java
Outdated
Show resolved
Hide resolved
...-storage-opensearch2/src/main/java/org/graylog/storage/opensearch2/MoreSearchAdapterOS2.java
Outdated
Show resolved
Hide resolved
...orage-opensearch2/src/main/java/org/graylog/storage/opensearch2/views/OpenSearchBackend.java
Outdated
Show resolved
Hide resolved
…are no available indices
...storage-elasticsearch7/src/main/java/org/graylog/storage/elasticsearch7/ScrollResultES7.java
Show resolved
Hide resolved
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.
LGTM!
* set option ignore_unavailable * CL * suppress missing index exception in event query * unit tests * ignore failing scroll request * more strict index options * add comments * use symbolic constants * No exception when search request returns no scrollID value and there are no available indices * annotate nullable --------- Co-authored-by: luk-kaminski <[email protected]> (cherry picked from commit 7acdc1d)
* Set option ignore_unavailable for querying (#18146) * set option ignore_unavailable * CL * suppress missing index exception in event query * unit tests * ignore failing scroll request * more strict index options * add comments * use symbolic constants * No exception when search request returns no scrollID value and there are no available indices * annotate nullable --------- Co-authored-by: luk-kaminski <[email protected]> (cherry picked from commit 7acdc1d) * fix merge
Resolves #18127
Description
When issuing a simple search query we now set option
ignoreUnavailable=true
andallowNoIndices=true
. This serves to suppress the exception in case of missing indices, but otherwise leaves behavior unaltered.In the case of scroll requests we also catch and handle the exception raised by empty results.
Motivation and Context
Avoid exceptions when there is a race between querying and deleting an index. See linked issue for details.