-
Notifications
You must be signed in to change notification settings - Fork 14.4k
KAFKA-17747: [6/N] Replace subscription metadata with metadata hash in share group #19796
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
Conversation
…e group Signed-off-by: PoAn Yang <[email protected]>
Signed-off-by: PoAn Yang <[email protected]>
This one should basically be a copy of #19761. Let's merge that one first and then we can review this one. |
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.
Thanks for the PR. I have only just started reviewing and will have more comments.
Because you are removing ShareGroupPartitionMetadata
, you should make some changes to CoordinatorRecordType.java
also I think. Essentially, ordinal 9 in the enum is no longer used (and could be used in the future).
@AndrewJSchofield The |
Ah, yes, I see. It's fine. One day, someone might notice that 9 is unused and then assign a new record type to it. The way that you've got it is fine. I just had to clone your branch and build it :) |
Signed-off-by: PoAn Yang <[email protected]>
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.
@FrankYang0529 thanks for this patch. two small comments are left. PTAL
// Add group epoch record. | ||
records.add(GroupCoordinatorRecordHelpers.newShareGroupEpochRecord(groupId, groupEpoch, 0)); | ||
records.add(GroupCoordinatorRecordHelpers.newShareGroupEpochRecord(groupId, groupEpoch, metadataHash)); |
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.
Should we calculate the metadataHash
if it is not defined? That is analogous to subscriptionMetadata
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.
Thanks for the suggestion. The subscriptionMetadata
can be null, so we can determine whether a developer sets the value. However, the metadataHash
is long and cannot be null. I would prefer to let the developer to set it manually.
if (topicImage != null) { | ||
Set<Integer> alreadyInitializedPartSet = alreadyInitialized.containsKey(topicImage.id()) ? alreadyInitialized.get(topicImage.id()).partitions() : Set.of(); | ||
if (alreadyInitializedPartSet.isEmpty() || alreadyInitializedPartSet.size() < topicImage.partitions().size()) { | ||
Set<Integer> partitionSet = IntStream.range(0, topicImage.partitions().size()).boxed().collect(Collectors.toSet()); |
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.
Could you consider using alreadyInitializedPartSet
to filter out the partitions from partitionSet
?
Set<Integer> partitionSet = IntStream.range(0, topicImage.partitions().size()).boxed()
.filter(p -> !alreadyInitializedPartSet.contains(p)).collect(Collectors.toSet());
It could be a small optimization, I guess :)
Signed-off-by: PoAn Yang <[email protected]>
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.
Thanks for the PR. Apart from one tiny nit, this looks like a faithful copy of the equivalent changes for consumer groups. I'll download the patch and try it on my local environment, but I expect we'll be good to merge for 4.1.
} | ||
|
||
if (bumpGroupEpoch) { | ||
groupEpoch += 1; | ||
records.add(newShareGroupEpochRecord(groupId, groupEpoch, 0)); | ||
records.add(newShareGroupEpochRecord(groupId, groupEpoch, groupMetadataHash)); | ||
log.info("[GroupId {}] Bumped group epoch to {}.", groupId, groupEpoch); |
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.
nit: This log includes the metadata hash in consumer groups. Seems sensible here too.
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.
Updated it. Thanks.
Signed-off-by: PoAn Yang <[email protected]>
@AndrewJSchofield, There is no |
@FrankYang0529 Could we use the share group describe method from the admin client? |
@FrankYang0529 I think you are planning a follow-on PR with additional testing when rebalance occurs. Apart from that future work, this looks ready to merge. |
@AndrewJSchofield I tried to add an integration test. However, the The consumer group uses kafka/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java Lines 351 to 354 in b1ea280
kafka/group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java Lines 374 to 375 in b1ea280
|
Ah, yes, good catch. We missed this config. I have created a specific issue https://issues.apache.org/jira/browse/KAFKA-19369. Given that KIP-932 does not permit a list of assignors, the only thing a user could do is implement their own assignor and replace the simple one. We've essentially hard-coded the |
ShareGroupPartitionMetadataKey
andShareGroupPartitionMetadataValue
.subscriptionTopicNames
andmetadataImage
to replacesubscriptionMetadata
insubscribedTopicsChangeMap
function.Reviewers: Chia-Ping Tsai [email protected], David Jacot
[email protected], Andrew Schofield [email protected]