Propagate status codes from shard failures appropriately#118016
Merged
pawankartik-elastic merged 19 commits intoelastic:mainfrom Dec 23, 2024
Merged
Propagate status codes from shard failures appropriately#118016pawankartik-elastic merged 19 commits intoelastic:mainfrom
pawankartik-elastic merged 19 commits intoelastic:mainfrom
Conversation
b185f74 to
d14cc28
Compare
…dException` and undo `status()` override in `NodeDisconnectedException`
d14cc28 to
eb334fd
Compare
DaveCTurner
previously requested changes
Dec 5, 2024
server/src/main/java/org/elasticsearch/transport/NodeNotConnectedException.java
Outdated
Show resolved
Hide resolved
Walking the stacktrace explicitly and looking for a specific error (node connection-related errors in this case) is a workaround rather than a proper fix. Instead, let the status codes propagate all the way to the top so that they can be reported as-is.
DaveCTurner
reviewed
Dec 9, 2024
Contributor
DaveCTurner
left a comment
There was a problem hiding this comment.
I have no strong opinions about the implementation of SearchPhaseExecutionException#status(), this is something that the search-foundations team should review.
We shouldn't be changing the ConnectTransportException subclasses here.
server/src/main/java/org/elasticsearch/transport/NodeDisconnectedException.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/transport/NodeNotConnectedException.java
Outdated
Show resolved
Hide resolved
NodeNotConnectedException4xx status codes are not likely to appear along with 5xx status codes. As a result, we do not need to account for them when looking at shard failures' status codes.
In reference to the previous commit: this case is no longer needed.
javanna
reviewed
Dec 19, 2024
Contributor
javanna
left a comment
There was a problem hiding this comment.
left two comments and questions, thanks!
server/src/main/java/org/elasticsearch/action/search/SearchPhaseExecutionException.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/rest/RestResponseTests.java
Outdated
Show resolved
Hide resolved
javanna
approved these changes
Dec 19, 2024
Contributor
javanna
left a comment
There was a problem hiding this comment.
LGTM thanks @pawankartik-elastic !
Collaborator
|
Hi @pawankartik-elastic, I've created a changelog YAML for you. |
Changes have been addressed and were reviewed by a member of the Search team.
Collaborator
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
pawankartik-elastic
added a commit
to pawankartik-elastic/elasticsearch
that referenced
this pull request
Dec 23, 2024
) * Return 502 if the underlying error is `NodeNotConnectedException` * Traverse through the cause stack trace and check for `NodeNotConnectedException` and undo `status()` override in `NodeDisconnectedException` * Rewrite `while` condition * Fix: precommit * Let status codes propagate rather than walking the stacktrace explicitly Walking the stacktrace explicitly and looking for a specific error (node connection-related errors in this case) is a workaround rather than a proper fix. Instead, let the status codes propagate all the way to the top so that they can be reported as-is. * Fix: unused import * Fix null deref * Do not map descendants of `ConnectTransportException` to `502` * Fix: precommit * Do not account for 4xx status codes 4xx status codes are not likely to appear along with 5xx status codes. As a result, we do not need to account for them when looking at shard failures' status codes. * Remove unnecessary `switch` case In reference to the previous commit: this case is no longer needed. * Rewrite code comment * Address review comments * [CI] Auto commit changes from spotless * Update docs/changelog/118016.yaml --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Collaborator
💚 Backport successful
|
elasticsearchmachine
pushed a commit
that referenced
this pull request
Dec 23, 2024
…119205) * Return 502 if the underlying error is `NodeNotConnectedException` * Traverse through the cause stack trace and check for `NodeNotConnectedException` and undo `status()` override in `NodeDisconnectedException` * Rewrite `while` condition * Fix: precommit * Let status codes propagate rather than walking the stacktrace explicitly Walking the stacktrace explicitly and looking for a specific error (node connection-related errors in this case) is a workaround rather than a proper fix. Instead, let the status codes propagate all the way to the top so that they can be reported as-is. * Fix: unused import * Fix null deref * Do not map descendants of `ConnectTransportException` to `502` * Fix: precommit * Do not account for 4xx status codes 4xx status codes are not likely to appear along with 5xx status codes. As a result, we do not need to account for them when looking at shard failures' status codes. * Remove unnecessary `switch` case In reference to the previous commit: this case is no longer needed. * Rewrite code comment * Address review comments * [CI] Auto commit changes from spotless * Update docs/changelog/118016.yaml --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the underlying error caused is
NodeNotConnectedExceptionand the reason isconnection already closed, the status code that should be returned is 502 rather than 500. This allows Kibana to retry the search op.Edit: the scope of this PR itself has changed since I first worked on it. The goal of this PR is to let the status code propagate so that it is returned back to the user appropriately. There's a separate task to map out
Exception-s to502; hence I'll be removing the related code form this PR. Adding this edit to let the readers understand how the scope has evolved.Relates ES-10191.
Fixes #118482.