-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Make list-tasks API cancellable #96283
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
Make list-tasks API cancellable #96283
Conversation
In a busy cluster the list-tasks API may retain information about a very large number of tasks while waiting for all nodes to respond. This commit makes the API cancellable so that unnecessary partial results can be released earlier. Relates elastic#96279, which implements the early-release functionality.
Pinging @elastic/es-distributed (Team:Distributed) |
tasksCancellable.cancel(); | ||
|
||
final var taskManagers = new ArrayList<TaskManager>(internalCluster().getNodeNames().length); | ||
for (final var transportService : internalCluster().getInstances(TransportService.class)) { |
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's pity that internalCluster().getInstances
returns Iterable
, but it's actually a list. Otherwise, we could perform a check just with the Streams API.
internalCluster().getInstances(TransportService.class)
.stream()
.map(TransportService::getTaskManager)
.flatMap(taskManager -> taskManager.getCancellableTasks().values().stream())
.anyMatch(t -> t.getAction().startsWith(ListTasksAction.NAME));
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 David
In a busy cluster the list-tasks API may retain information about a very large number of tasks while waiting for all nodes to respond. This commit makes the API cancellable so that unnecessary partial results can be released earlier.
Relates #96279, which implements the early-release functionality.