-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add support for task cancellation to TransportMasterNodeAction #72157
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
Add support for task cancellation to TransportMasterNodeAction #72157
Conversation
|
Pinging @elastic/es-distributed (Team:Distributed) |
DaveCTurner
left a comment
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.
Looks good, but I think we should also check for cancellation while we're trying to route the request to the master in the first place. Specifically at the top of doStart(), and IMO we should also adjust the predicate passed into the ClusterStateObserver so that it runs doStart() on the first state update after cancellation.
|
Thanks for the review!, those are good suggestions. I added the checks to cover these cases too. |
| private void executeMasterOperation(Task task, Request request, ClusterState state, | ||
| ActionListener<Response> listener) throws Exception { | ||
| if (task instanceof CancellableTask && ((CancellableTask) task).isCancelled()) { | ||
| throw new CancellationException("Task was cancelled"); |
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 don't think we exercise this in the tests any more? At least I removed it and the tests still passed several hundred iterations.
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 added a new test for this scenario in c1da23f
| final ClusterState.Builder newStateBuilder = ClusterState.builder(stateWithBlock); | ||
|
|
||
| // Either unblock the cluster state or just do an unrelated cluster state change that will check | ||
| // if the task has been cancelled |
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.
Nice.
DaveCTurner
left a comment
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 👍
|
@elasticmachine update branch |
In elastic#72157 we made it so that cancelling the task that a `TransportMasterNodeAction` was executing causes the action to fail with a `java.util.concurrent.CancellationException`. This exception is treated as a `500 Internal Server Error` which results in `WARN`-level logs, but cancelling a task is normal and expected behaviour and should not be logged (see elastic#73524). This commit fixes this by using a `TaskCancelledException` instead, since this exception maps to a `400 Bad Request` and generates no logs.
In #72157 we made it so that cancelling the task that a `TransportMasterNodeAction` was executing causes the action to fail with a `java.util.concurrent.CancellationException`. This exception is treated as a `500 Internal Server Error` which results in `WARN`-level logs, but cancelling a task is normal and expected behaviour and should not be logged (see #73524). This commit fixes this by using a `TaskCancelledException` instead, since this exception maps to a `400 Bad Request` and generates no logs.
In elastic#72157 we made it so that cancelling the task that a `TransportMasterNodeAction` was executing causes the action to fail with a `java.util.concurrent.CancellationException`. This exception is treated as a `500 Internal Server Error` which results in `WARN`-level logs, but cancelling a task is normal and expected behaviour and should not be logged (see elastic#73524). This commit fixes this by using a `TaskCancelledException` instead, since this exception maps to a `400 Bad Request` and generates no logs.
In #72157 we made it so that cancelling the task that a `TransportMasterNodeAction` was executing causes the action to fail with a `java.util.concurrent.CancellationException`. This exception is treated as a `500 Internal Server Error` which results in `WARN`-level logs, but cancelling a task is normal and expected behaviour and should not be logged (see #73524). This commit fixes this by using a `TaskCancelledException` instead, since this exception maps to a `400 Bad Request` and generates no logs.
This commit adds support for cancellation on TransportMasterNodeAction.
This is useful to provide cancellation for requests such as
TransportGetMappingsAction