fix rebalancing-tasks bug and added tests #900
Merged
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.
Problem:
Both the LoadBasedPartition and StickyPartition Strategy follow the StickyMulticastStrategy to assign the datastream tasks across the available instances.
In the StickyMulticastStrategy, the last step of the process is to rebalance the tasks across instances such that the number of tasks across the instances adheres to the
imbalance threshold
value.In the current implementation, there was a minor bug, which in some cases failed to achieve that proper rebalance. That issue causes validation failures and thus availability misses on the mirror-making service.
Failure Scenario: Observed in production service with 6 instances connected to ZK and has 538 tasks in total.
We saw from the production logs that the tasks were distributed across the instances with counts: 89, 89, 89, 89, 93, 89
And given that we enforce the imbalance threshold of 1, the actual distribution should have been something like
89, 89, 90, 90, 90, 90
In the below pasted rebalance code,
tasksTotal = 538
minTasksPerInstance = 538 / 6 = 89
And since the minimum number of tasks assigned == minTasksPerInstance, it won't go in the while loop to rebalance.
Solution:
Update the rebalancing code condition to only terminate when the min #tasks assigned + the imbalance threshold is less than the max #tasks assigned.
Important: DO NOT REPORT SECURITY ISSUES DIRECTLY ON GITHUB.
For reporting security issues and contributing security fixes,
please, email [email protected] instead, as described in
the contribution guidelines.
Please, take a minute to review the contribution guidelines at:
https://github.com/linkedin/Brooklin/blob/master/CONTRIBUTING.md