-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Propagate status codes from shard failures appropriately #118016
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
Propagate status codes from shard failures appropriately #118016
Conversation
b185f74
to
d14cc28
Compare
…dException` and undo `status()` override in `NodeDisconnectedException`
d14cc28
to
eb334fd
Compare
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.
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 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
NodeNotConnectedException
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.
In reference to the previous commit: this case is no longer needed.
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.
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
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 thanks @pawankartik-elastic !
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.
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
) * 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 <[email protected]>
💚 Backport successful
|
…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 <[email protected]>
If the underlying error caused is
NodeNotConnectedException
and 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.