Skip to content

Conversation

@DaveCTurner
Copy link
Contributor

The MasterService executes batches of tasks which compute changes to
the ClusterState. After executing each batch the MasterService
publishes the updated cluster state and may notify tasks in the batch
when the nodes have acked the state (or failed, or timed out). Many
tasks compute some kind of result during their execution which needs to
be made available to the ack completion handler for subsequent
activities.

Today there's no good general way to pass anything to the ack completion
handler other than the fact that the update was acked or not. Some tasks
work around this by storing their result in the ClusterState itself.
Others use the executor to capture the result and pass it through.
Neither solution works well with batching: later tasks in a batch may
overwrite the part of the ClusterState containing the results of
earlier tasks, and batching executors are re-used across batches.

This commit adjusts the ClusterStateTaskExecutor interface so that now
implementations that wish to listen for acks must supply a listener for
each task they successfully execute. The MasterService collects the
listeners for the batch and notifies them as acks are received. This
gives the executor control over the ack handler of each task which lets
it pass in any extra data needed.

Effectively this is the same as #83562 but for ack listeners instead of
publish listeners.

@DaveCTurner DaveCTurner added WIP :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. v8.2.0 labels Feb 19, 2022
The `MasterService` executes batches of tasks which compute changes to
the `ClusterState`. After executing each batch the `MasterService`
publishes the updated cluster state and may notify tasks in the batch
when the nodes have acked the state (or failed, or timed out). Many
tasks compute some kind of result during their execution which needs to
be made available to the ack completion handler for subsequent
activities.

Today there's no good general way to pass anything to the ack completion
handler other than the fact that the update was acked or not. Some tasks
work around this by storing their result in the `ClusterState` itself.
Others use the executor to capture the result and pass it through.
Neither solution works well with batching: later tasks in a batch may
overwrite the part of the `ClusterState` containing the results of
earlier tasks, and batching executors are re-used across batches.

This commit adjusts the `ClusterStateTaskExecutor` interface so that now
implementations that wish to listen for acks must supply a listener for
each task they successfully execute. The `MasterService` collects the
listeners for the batch and notifies them as acks are received. This
gives the executor control over the ack handler of each task which lets
it pass in any extra data needed.

Effectively this is the same as elastic#83562 but for ack listeners instead of
publish listeners.
@DaveCTurner DaveCTurner force-pushed the 2022-02-21-master-service-non-void-ack-result branch from 9b8fa13 to 10a1ac8 Compare February 19, 2022 17:44
@DaveCTurner DaveCTurner marked this pull request as ready for review February 21, 2022 11:15
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Feb 21, 2022
@elasticmachine
Copy link
Collaborator

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

@DaveCTurner
Copy link
Contributor Author

@elasticmachine update branch

@DaveCTurner
Copy link
Contributor Author

This PR is extracted from #84170 which also uses these changes to rework AutoCreateAction - it might be instructive to look at how it's used there.

Copy link
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM

@DaveCTurner DaveCTurner added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Feb 22, 2022
@DaveCTurner
Copy link
Contributor Author

@elasticmachine please run elasticsearch-ci/part-2 (failure reported at #84232)

@elasticsearchmachine elasticsearchmachine merged commit 9e651fa into elastic:master Feb 22, 2022
@DaveCTurner DaveCTurner deleted the 2022-02-21-master-service-non-void-ack-result branch February 22, 2022 16:39
probakowski pushed a commit to probakowski/elasticsearch that referenced this pull request Feb 23, 2022
The `MasterService` executes batches of tasks which compute changes to
the `ClusterState`. After executing each batch the `MasterService`
publishes the updated cluster state and may notify tasks in the batch
when the nodes have acked the state (or failed, or timed out). Many
tasks compute some kind of result during their execution which needs to
be made available to the ack completion handler for subsequent
activities.

Today there's no good general way to pass anything to the ack completion
handler other than the fact that the update was acked or not. Some tasks
work around this by storing their result in the `ClusterState` itself.
Others use the executor to capture the result and pass it through.
Neither solution works well with batching: later tasks in a batch may
overwrite the part of the `ClusterState` containing the results of
earlier tasks, and batching executors are re-used across batches.

This commit adjusts the `ClusterStateTaskExecutor` interface so that now
implementations that wish to listen for acks must supply a listener for
each task they successfully execute. The `MasterService` collects the
listeners for the batch and notifies them as acks are received. This
gives the executor control over the ack handler of each task which lets
it pass in any extra data needed.

Effectively this is the same as elastic#83562 but for ack listeners instead of
publish listeners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. >refactoring Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants