KAFKA-13783; Remove reason prefixing in JoinGroupRequest and LeaveGroupRequest#11971
KAFKA-13783; Remove reason prefixing in JoinGroupRequest and LeaveGroupRequest#11971dajac merged 4 commits intoapache:trunkfrom
Conversation
|
I'll take a look tomorrow. Thanks. |
|
cc @cadonna I'd like to get this one in 3.2. |
|
@dajac Please go ahead! |
| List<MemberIdentity> membersToRemove = new ArrayList<>(); | ||
| for (final MemberDescription member : members) { | ||
| MemberIdentity memberIdentity = new MemberIdentity() | ||
| .setReason(reason); |
There was a problem hiding this comment.
QQ: seems reason is also used in equals, is it ok to add this? Will this cause membersToRemove not found from somewhere?
There was a problem hiding this comment.
Good question. Let me double check this. For the context, we were doing this before this patch as well.
There was a problem hiding this comment.
This does not seem to be an issue. I have extended the unit test to ensure that the look up works as we expect.
There was a problem hiding this comment.
nit: does .setReason() have to be in its own line?
jeffkbkim
left a comment
There was a problem hiding this comment.
Thanks for the PR! left a few comments
| List<MemberIdentity> membersToRemove = new ArrayList<>(); | ||
| for (final MemberDescription member : members) { | ||
| MemberIdentity memberIdentity = new MemberIdentity() | ||
| .setReason(reason); |
There was a problem hiding this comment.
nit: does .setReason() have to be in its own line?
|
|
||
| // a first rebalance to get the assignment, we need two poll calls since we need two round trips to finish join / sync-group | ||
| consumer.poll(Duration.ZERO); | ||
| consumer.poll(Duration.ZERO); |
There was a problem hiding this comment.
the test passes without the second poll. the first poll finishes the sync
INFO Successfully synced group in generation
before the second poll is triggered.
The second poll notifies the assignor and gets committed offsets which i don't think is necessary in this test
There was a problem hiding this comment.
I think what we want is to wait for rebalance complete. we can explicitly wait like this:
TestUtils.waitForCondition(() -> {
ConsumerRecords<String, String> recs = consumer.poll(Duration.ofMillis(100L));
return consumer.assignment().equals(Utils.mkSet(tp0, t2p0));
});WDYT?
There was a problem hiding this comment.
I just refactored this test based on @jeffkbkim's comment. In the end, we only care about the join group call in this context so I have changed the test to only care about this part.
| String reason = options.reason() == null || options.reason().isEmpty() ? | ||
| DEFAULT_LEAVE_GROUP_REASON : options.reason(); | ||
|
|
||
| List<MemberIdentity> members; | ||
| if (options.removeAll()) { | ||
| members = getMembersFromGroup(groupId); | ||
| members = getMembersFromGroup(groupId, reason); | ||
| } else { | ||
| members = options.members().stream().map(MemberToRemove::toMemberIdentity).collect(Collectors.toList()); | ||
| members = options.members().stream() | ||
| .map(m -> m.toMemberIdentity().setReason(reason)) | ||
| .collect(Collectors.toList()); |
There was a problem hiding this comment.
should this have been done as part of KIP-800?
There was a problem hiding this comment.
This is a small refactoring of the code that we did in KIP-800. It basically set the reason when the member identity is created instead of re-iterating over the members afterwards. I think that it is a bit clearer this way. I guess that we could have done like this in the original implementation but I did not think about it last time.
showuon
left a comment
There was a problem hiding this comment.
Thanks for the PR. LGTM! Left a minor comment. Thanks.
|
|
||
| // a first rebalance to get the assignment, we need two poll calls since we need two round trips to finish join / sync-group | ||
| consumer.poll(Duration.ZERO); | ||
| consumer.poll(Duration.ZERO); |
There was a problem hiding this comment.
I think what we want is to wait for rebalance complete. we can explicitly wait like this:
TestUtils.waitForCondition(() -> {
ConsumerRecords<String, String> recs = consumer.poll(Duration.ofMillis(100L));
return consumer.assignment().equals(Utils.mkSet(tp0, t2p0));
});WDYT?
|
@jeffkbkim @showuon Thanks for your comments. I have addressed them. |
…upRequest (#11971) KIP-800 introduced a mechanism to pass a reason in the join group request and in the leave group request. A default reason is used unless one is provided by the user. In this case, the custom reason is prefixed by the default one. When we tried to used this in Kafka Streams, we noted a significant degradation of the performances, see #11873. It is not clear wether the prefixing is the root cause of the issue or not. To be on the safe side, I think that we should remove the prefixing. It does not bring much anyway as we are still able to distinguish a custom reason from the default one on the broker side. This patch removes prefixing the user provided reasons. So if a the user provides a reason, the reason is used directly. If the reason is empty or null, the default reason is used. Reviewers: Luke Chen <showuon@gmail.com>, <jeff.kim@confluent.io>, Hao Li <hli@confluent.io>
|
Merged to trunk and to 3.2. |
|
Can we make sure this actually helps with the benchmark that previously regressed? |
|
@lihaosky Could you please try to re-add the leave reason in Streams and re-run the benchmarks? |
|
Sure thing! |
|
We have found the root cause of the original issue. It was a bug in our benchmark setup so it had nothing to do with this change in the end. We can still keep this change as it looks better to me like this. |
Thanks for the update. Great to hear that! |
KIP-800 introduced a mechanism to pass a reason in the join group request and in the leaver group request. A default reason is used unless one is provided by the user. In this case, the custom reason is prefixed by the default one.
When we tried to used this in Kafka Streams, we noted a significant degradation of the performances, see #11873. It is not clear wether the prefixing is the root cause of the issue or not. To be on the safe side, I think that we should remove the prefixing. It does not bring much anyway as we are still able to distinguish a custom reason from the default one on the broker side.
This patch removes prefixing the user provided reasons. So if a the user provides a reason, the reason is used directly. If the reason is empty or null, the default reason is used.
Committer Checklist (excluded from commit message)