[1.x] Distinguish shard pick-up results#1505
Merged
Merged
Conversation
added 6 commits
March 29, 2023 10:38
armiol
requested changes
Mar 29, 2023
added 7 commits
March 31, 2023 13:21
armiol
requested changes
Apr 3, 2023
Contributor
armiol
left a comment
There was a problem hiding this comment.
@nick-dolgiy please see my comments.
added 6 commits
April 3, 2023 12:44
…eadyPicked()` handler.
Author
Done. |
Author
|
@armiol PTAL. |
armiol
requested changes
Apr 12, 2023
Contributor
armiol
left a comment
There was a problem hiding this comment.
@nick-dolgiy please see my comments.
Author
|
@armiol PTAL. |
armiol
requested changes
Apr 13, 2023
Contributor
armiol
left a comment
There was a problem hiding this comment.
@nick-dolgiy one last thing, hopefully. Please see my comment.
Otherwise, LGTM.
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.
In this PR we start to distinguish the shard pick-up results. In particular, it is now possible to find out the reason of an unsuccessful shard pick-up. In particular, there may be some runtime issues, or the shard may already be picked-up by another worker.
Two new API endpoints were added to the
DeliveryMonitorto provide end-users with some control over such cases:FailedPickUp.Action onShardAlreadyPicked(AlreadyPickedUp failure)This method will be invoked if the shard could not be picked as it's already picked by another worker. This method receives the
ShardIndexof the shard that could not be picked, theWorkerIdof the worker who owns the delivery session, and theTimestampwhen the shard was picked. It is required to return an action to take in relation to this case. By default, it returns an action which just accepts this case (and ends the delivery session without any processing), but end-users may return a predefined action retrying the shard pick-up:FailedPickUp.Action onShardPickUpFailure(RuntimeFailure failure)This method is invoked if the shard could not be picked for some runtime technical reason, such as a runtime exception. This method receives the
ShardIndexof the shard that could not be picked, and the instance of the occurredException. It also requires to return an action to handle this case. By default, such failures are just rethrown asRuntimeException, but end-users may choose to retry the pick-up:Breaking changes
The API of the
ShardedWorkRegistryhas been changed.In particular, a new
PickUpOutcome pickUp(ShardIndex index, NodeId node)method is introduced. Note, it returns an explicit result instead ofOptional, as previously. This outcome contains either of two:ShardSessionRecord— meaning that the shard is picked successfully,ShardAlreadyPickedUp— a message that contains aWorkerIDof the worker who owns the session at the moment, and theTimestampwhen the shard was picked. This outcome means the session cannot be obtained as it's already picked.Also, there is a new
void release(ShardSessionRecord session)method that releases the passed session.Here is a summary of code changes for those using
ShardedWorkRegistry:Before:
After:
Also, the new API allows getting the
WorkerIdof the worker who owns the session in case if the shard is already picked by someone else and theTimestampwhen the shard was picked: