Return result to cluster state ack listener#84174
Merged
elasticsearchmachine merged 3 commits intoelastic:masterfrom Feb 22, 2022
Merged
Conversation
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.
9b8fa13 to
10a1ac8
Compare
Collaborator
|
Pinging @elastic/es-distributed (Team:Distributed) |
Member
Author
|
@elasticmachine update branch |
Member
Author
|
This PR is extracted from #84170 which also uses these changes to rework |
Member
Author
|
@elasticmachine please run elasticsearch-ci/part-2 (failure reported at #84232) |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
MasterServiceexecutes batches of tasks which compute changes tothe
ClusterState. After executing each batch theMasterServicepublishes 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
ClusterStateitself.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
ClusterStatecontaining the results ofearlier tasks, and batching executors are re-used across batches.
This commit adjusts the
ClusterStateTaskExecutorinterface so that nowimplementations that wish to listen for acks must supply a listener for
each task they successfully execute. The
MasterServicecollects thelisteners 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.