KAFKA-6718 / Rack aware standby task assignor#10851
Conversation
|
Call for review @cadonna @vvcephei @ableegoldman |
|
gentle nudge @cadonna @vvcephei @ableegoldman |
|
@lkokhreidze Sorry for the long silence! Some other tasks got in my way. I plan to review this PR tomorrow. |
cadonna
left a comment
There was a problem hiding this comment.
@lkokhreidze Thank you for the PR!
I did a first pass. Here is my feedback.
…nals/assignment/DefaultStandbyTaskAssignor.java Co-authored-by: Bruno Cadonna <cadonna@apache.org>
…; Remove NoopStandbyTaskAssignor;
|
Thanks @cadonna for the feedback. |
cadonna
left a comment
There was a problem hiding this comment.
@lkokhreidze Thank you for the updates!
Here my next round of feedback!
…ignature change of HighAvailabilityTaskAssignor#assignActiveStatefulTasks
|
Thanks @cadonna for the valuable feedback 🙇 |
|
@lkokhreidze FYI: I will be offline the next two weeks. I am sorry that I haven't had time to review this PR this week. |
|
Hi @cadonna ! |
…reidze/kafka into KAFKA-6718-standby-task-assignment
|
Thanks @showuon for the valuable feedback. |
…mberOfStandbyTasksEqualsTo
showuon
left a comment
There was a problem hiding this comment.
@lkokhreidze , thanks for the update. Overall LGTM! Only one question for partial rack awareness assignment. Thanks.
| // If we have used more clients than all the tag's unique values, | ||
| // we can't filter out clients located on that tag, because it'll exclude all the clients. | ||
| // Instead, we need to discard all the clients that were marked as "used" on that tag key values. | ||
| // Please check ClientTagAwareStandbyTaskAssignorTest#shouldDoThePartialRackAwareness test for more info. |
There was a problem hiding this comment.
That is quite challenging to understand. After reading it a couple of times I understood that if we've used a number of clients that is equal to or greater than the number of unique values of the tag, we cannot guarantee that each standby is on a different tag value than the active and other standbys. So the rack-awareness becomes partial. Is that correct?
Could you reformulate it, so that it states that the rack-awareness guarantee does not hold anymore.
And why "more clients than all tag's unique values"? When the number of used clients is equal to the unique tag values, we are already in the partial rack-awareness situation, right?
Maybe you should give here an example as in the mentioned test. I find referencing the test is a bit cumbersome, because if the test gets renamed this comment becomes useless.
There was a problem hiding this comment.
Thanks Bruno, I'll add the example to the comment.
There was a problem hiding this comment.
Pushed the changes. I added detailed explanation with an example. Also tests have the similar example. Hopefully this change makes logic more clear.
| final int numStandbyReplicas = configs.numStandbyReplicas; | ||
| final Set<String> rackAwareAssignmentTags = new HashSet<>(configs.rackAwareAssignmentTags); | ||
|
|
||
| final Map<TaskId, Integer> tasksToRemainingStandbys = computeTasksToRemainingStandbys( |
There was a problem hiding this comment.
I could not find where you decrement the number of remaining standbys. If you get a value from this map and put it into an int variable, you do not have a reference to the Integer value in the map anymore. This might become a problem in StandbyTaskAssignmentUtils#pollClientAndMaybeAssignRemainingStandbyTasks().
There was a problem hiding this comment.
Nice catch! And maybe we should add a test to address this.
There was a problem hiding this comment.
Yes, a test is absolutely necessary!
There was a problem hiding this comment.
Updated tests for the StandbyTaskAssignmentUtils#pollClientAndMaybeAssignAndUpdateRemainingStandbyTasks and also added separate test for the ClientTagAwareStandbyTaskAssignor.
For the ClientTagAwareStandbyTaskAssignor I decided to make few things package private to be able to test this logic. As otherwise, there was no easy way to test if tasksToRemainingStandbys was getting updated properly. Hope this is okay.
…nals/assignment/ClientTagAwareStandbyTaskAssignor.java Co-authored-by: Bruno Cadonna <cadonna@apache.org>
showuon
left a comment
There was a problem hiding this comment.
Thanks for the update in partial rack awareness assignment. LGTM! Left some minor comments. Thanks.
| final int numStandbyReplicas = configs.numStandbyReplicas; | ||
| final Set<String> rackAwareAssignmentTags = new HashSet<>(configs.rackAwareAssignmentTags); | ||
|
|
||
| final Map<TaskId, Integer> tasksToRemainingStandbys = computeTasksToRemainingStandbys( |
There was a problem hiding this comment.
Nice catch! And maybe we should add a test to address this.
showuon
left a comment
There was a problem hiding this comment.
Thanks for the update. I'll check the test code tomorrow.
showuon
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the improvement!
|
Hi @cadonna |
|
@lkokhreidze I will try to have a look this week. I would also like to get this PR merged as soon as possible. Since @showuon has already approved it. If I will not manage to have a look, @showuon can merge it. |
cadonna
left a comment
There was a problem hiding this comment.
@lkokhreidze Thanks a lot for this PR!
Sorry for all the delay!
LGTM! I had just some minor comments that can be addressed in a follow-up PR.
As I pointed out in one of my comments, I am not a big fan of // Visible for testing because that often indicates some deficiencies in the modularization. But this is nothing that cannot be addressed in a follow-up PR. So I am fine with merging it.
| } | ||
|
|
||
| if (!tasksToRemainingStandbys.isEmpty()) { | ||
| log.debug("Rack aware standby task assignment was not able to assign all standby tasks. " + |
There was a problem hiding this comment.
I think info log would also be OK here. I imagine users that are wondering why their standbys are not distributed as they would expect. With this information they can at least try to fix it on the config level. This log message should only happen at rebalance time, which should usually be rather seldom.
If we decide to put the log message on info level, you should also change a bit the wording and not use variable names in it. Maybe some hints what the users can do to fix this would also be nice.
Is it possible to separate the concerns of this log message and the one on line 135? Something along the lines of here the rack-aware standby assignment did not work due the tag config and on line 135 the assignment did not work due to too low number of instances. We can then put both on warn or info (do not forget to also check the related log message in the default standby assignor).
| // Visible for testing | ||
| static StandbyTaskAssignor createStandbyTaskAssignor(final AssignmentConfigs configs) { | ||
| if (!configs.rackAwareAssignmentTags.isEmpty()) { | ||
| return new ClientTagAwareStandbyTaskAssignor(); | ||
| } else { | ||
| return new DefaultStandbyTaskAssignor(); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This can be done in a follow-up PR:
I am not a big fan of // Visible for testing because it often means that we missed to extract code to separate classes. Here I would definitely extract this code to a factory class.
|
@lkokhreidze Let me know if you want to address my minor comments in this PR. After that @showuon or I can merge this PR. Nice work! |
…nals/assignment/ClientTagAwareStandbyTaskAssignor.java Co-authored-by: Bruno Cadonna <cadonna@apache.org>
…nals/assignment/ClientTagAwareStandbyTaskAssignor.java Co-authored-by: Bruno Cadonna <cadonna@apache.org>
|
Hi @cadonna , thanks for the review. Thank you! |
|
Failed tests are unrelated and also failed in |
|
🥳 |
This PR is part of KIP-708 and adds rack aware standby task assignment logic. Rack aware standby task assignment won't be functional until all parts of this KIP gets merged. Splitting PRs into three smaller PRs to make the review process easier to follow. Overall plan is the following: ⏭️ Rack aware standby task assignment logic #10851 ⏭️ Protocol change, add clientTags to SubscriptionInfoData #10802 👉 Add required configurations to StreamsConfig (public API change, at this point we should have full functionality) This PR implements last point of the above mentioned plan. Reviewers: Luke Chen <showuon@gmail.com>, Bruno Cadonna <cadonna@apache.org>
This PR is part of KIP-708 and adds rack aware standby task assignment logic.
Rack aware standby task assignment won't be functional until all parts of this KIP gets merged.
Splitting PRs into three smaller PRs to make the review process easier to follow. Overall plan is the following:
👉 Rack aware standby task assignment logic.
⏭️ Protocol change, add clientTags to SubscriptionInfoData #10802
⏭️ Add required configurations to StreamsConfig (public API change, at this point we should have full functionality) #11837
This PR implements first point of the above mentioned plan.
Committer Checklist (excluded from commit message)