Skip to content

Conversation

DaveCTurner
Copy link
Contributor

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.

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.
@DaveCTurner DaveCTurner added >non-issue :Distributed Coordination/Task Management Issues for anything around the Tasks API - both persistent and node level. v8.9.0 labels May 23, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label May 23, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@DaveCTurner DaveCTurner requested review from arteam and pxsalehi May 30, 2023 07:44
tasksCancellable.cancel();

final var taskManagers = new ArrayList<TaskManager>(internalCluster().getNodeNames().length);
for (final var transportService : internalCluster().getInstances(TransportService.class)) {
Copy link
Contributor

@arteam arteam May 30, 2023

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));

Copy link
Contributor

@arteam arteam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks David

@DaveCTurner DaveCTurner merged commit e5111e3 into elastic:main May 30, 2023
@DaveCTurner DaveCTurner deleted the 2023-05-23-ListTasks-cancellable branch May 30, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Task Management Issues for anything around the Tasks API - both persistent and node level. >non-issue Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants