-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Return result to cluster state ack listener #84174
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
Return result to cluster state ack listener #84174
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
|
Pinging @elastic/es-distributed (Team:Distributed) |
|
@elasticmachine update branch |
|
This PR is extracted from #84170 which also uses these changes to rework |
original-brownbear
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 please run elasticsearch-ci/part-2 (failure reported at #84232) |
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.
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.