Skip to content

KAFKA-16894: Exploit share feature [3/N] #19542

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

Merged
merged 6 commits into from
Apr 30, 2025

Conversation

AndrewJSchofield
Copy link
Member

@AndrewJSchofield AndrewJSchofield commented Apr 23, 2025

This PR uses the v1 of the ShareVersion feature to enable share groups
for KIP-932.

Previously, there were two potential configs which could be used -
group.share.enable=true and including "share" in
group.coordinator.rebalance.protocols. After this PR, the first of
these is retained, but the second is not. Instead, the preferred switch
is the ShareVersion feature.

The group.share.enable config is temporarily retained for testing and
situations in which it is inconvenient to set the feature, but it should
really not be necessary, especially when we get to AK 4.2. The aim is to
remove this internal config at that point.

No tests should be setting group.share.enable any more, because they
can use the feature (which is enabled in test environments by default
because that's how features work). For tests which need to disable share
groups, they now set the share feature to v0. The majority of the code
changes were related to correct initialisation of the metadata cache in
tests now that a feature is used.

Copy link
Contributor

@apoorvmittal10 apoorvmittal10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, some questions and a minor comment.

Comment on lines -1854 to -1855
@ClusterConfigProperty(key = "group.coordinator.rebalance.protocols", value = "classic,consumer,share"),
@ClusterConfigProperty(key = "group.share.enable", value = "true"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testComplexShareConsumer in this file also has both properties specifed, shall we remove them as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

Comment on lines -633 to -634
if (config.shareGroupConfig.isShareGroupEnabled &&
config.shareGroupConfig.shareGroupPersisterClassName().nonEmpty) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So irrespective of feature flag or config the share-coordinator thread will run now. I think this is what you mentioned to be fixed in further PRs to start using feature listeners, correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

private def isShareGroupProtocolEnabled: Boolean = {
config.shareGroupConfig.isShareGroupEnabled
config.shareGroupConfig.isShareGroupEnabled || shareVersion().supportsShareGroups
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: So we have removed the config isShareGroupEnabled usage from BokerServer and tests but still uses in KafkaApis, why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the tests, the non-production features are automatically enabled. As a result, tests generally do not need to enable the feature. However, if you make a broker outside the test infrastructure, it will not have share groups enabled.

In the period of time that the feature is not enabled by default, having an internal config (group.share.enable) as a simple way to turn on share groups without using the feature is helpful. For situations in which creating a broker using config is automated or scripted, just adding group.share.enable=true to the config is very simple. The alternative using a feature is a bit more fiddly (either enable the feature when formatting the broker storage, or start the broker and then enable the feature with a second command)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other part of this of course is that BrokerServer unconditionally initialises the SharePartitionManager and share coordinator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining.

Comment on lines 11348 to 11357
val delta = new MetadataDelta(MetadataImage.EMPTY);
delta.replay(new FeatureLevelRecord()
.setName(MetadataVersion.FEATURE_NAME)
.setFeatureLevel(MetadataVersion.MINIMUM_VERSION.featureLevel())
)
delta.replay(new FeatureLevelRecord()
.setName(ShareVersion.FEATURE_NAME)
.setFeatureLevel(ShareVersion.SV_1.featureLevel())
)
cache.setImage(delta.apply(MetadataProvenance.EMPTY))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems repeating at a lot of instance, should we have a method to enable share groups which can be called in all the methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@apoorvmittal10 apoorvmittal10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, are we fixing this comment as well: #19542 (comment)?

@AndrewJSchofield
Copy link
Member Author

Looks good, are we fixing this comment as well: #19542 (comment)?

Thinking about it. Might make it a follow-on. That's a very large file and there's more tidying up that could usefully be done I think.

Copy link
Contributor

@apoorvmittal10 apoorvmittal10 left a 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, we will continue improving the handling gated with features in subsequent PRs.

@AndrewJSchofield AndrewJSchofield merged commit ce97b1d into apache:trunk Apr 30, 2025
22 checks passed
@AndrewJSchofield AndrewJSchofield deleted the KAFKA-16894-2 branch April 30, 2025 12:27
shmily7829 pushed a commit to shmily7829/kafka that referenced this pull request May 7, 2025
This PR uses the v1 of the ShareVersion feature to enable share groups
for KIP-932.

Previously, there were two potential configs which could be used -
`group.share.enable=true` and including "share" in
`group.coordinator.rebalance.protocols`. After this PR, the first of
these is retained, but the second is not. Instead, the preferred switch
is the ShareVersion feature.

The `group.share.enable` config is temporarily retained for testing and
situations in which it is inconvenient to set the feature, but it should
really not be necessary, especially when we get to AK 4.2. The aim is to
remove this internal config at that point.

No tests should be setting `group.share.enable` any more, because they
can use the feature (which is enabled in test environments by default
because that's how features work). For tests which need to disable share
groups, they now set the share feature to v0. The majority of the code
changes were related to correct initialisation of the metadata cache in
tests now that a feature is used.

Reviewers: Apoorv Mittal <[email protected]>
chia7712 pushed a commit that referenced this pull request May 11, 2025
…#19633)

Currently, the quorum uses kraft by default, so there's no need to
specify it explicitly.

For kip932 and isShareGroupTest, they are no longer used after #19542 .

Reviewers: PoAn Yang <[email protected]>, Ken Huang
 <[email protected]>, Chia-Ping Tsai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants