Skip to content

KAFKA-17492 skip features with minVersion of 0 instead of replacing 0 with 1 when BrokerRegistrationRequest < 4#17128

Merged
chia7712 merged 3 commits intoapache:trunkfrom
m1a2st:gh-KAFKA-17492
Sep 10, 2024
Merged

KAFKA-17492 skip features with minVersion of 0 instead of replacing 0 with 1 when BrokerRegistrationRequest < 4#17128
chia7712 merged 3 commits intoapache:trunkfrom
m1a2st:gh-KAFKA-17492

Conversation

@m1a2st
Copy link
Copy Markdown
Collaborator

@m1a2st m1a2st commented Sep 8, 2024

Jira: https://issues.apache.org/jira/browse/KAFKA-17492

Due to the BrokerRegistrationRequest minVersion is setting from 0 to 1, thus ClusterControlManger#processRegistrationFeature check the version will throw an error, fix it by below suggestion

  1. make 3.9+ broker be able to register to 3.8 controller
    skip features with minVersion of 0 instead of replacing 0 with 1 when BrokerRegistrationRequest < 4

2. make 3.9+ controller be able to accept unknown features from future broker
skip check of unknown features. see following sample code

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@chia7712
Copy link
Copy Markdown
Member

chia7712 commented Sep 8, 2024

make 3.9+ controller be able to accept unknown features from future broker

noticed that I had raised a question for it: #16421 (comment)

@m1a2st m1a2st marked this pull request as draft September 9, 2024 04:59
Copy link
Copy Markdown
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@m1a2st : Thanks for the PR. Left one comment.

} else {
return new BrokerRegistrationRequest(data, version);
}
return new BrokerRegistrationRequest(data, version);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to skip features with minSupportedVersion of 0 in v3 or less.

We need to do the same in ApiVersionResponse.

We need to change the comment like the following in ApiVersionResponse.json and BrokerRegistrationRequest.json.

Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for another: please update the following comment:

                // Workaround for KAFKA-17011: for BrokerRegistrationRequest versions older than 4,
                // translate minSupportedVersion = 0 to minSupportedVersion = 1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I don't understand the change here. The correct change (that matches the PR description) would be to remove features that had a minVersion of 0 when handling older RPCs, right? But instead the code just seems to pass everything through, ignoring RPC version. What am I missing?

@chia7712 chia7712 changed the title KAFKA-17492: Can't register 3.9+ broker to 3.8 controller since 3.8 controller assume the default version of feature is zero KAFKA-17492 skip features with minVersion of 0 instead of replacing 0 with 1 when BrokerRegistrationRequest < 4 Sep 9, 2024
". The broker wants a version between " + feature.minSupportedVersion() + " and " +
feature.maxSupportedVersion() + ", inclusive.");
}
finalizedFeatures.get(feature.name()).ifPresent(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@m1a2st please take a look at #16421 (comment). We don't need to remove the check of ClusterControlManager

". The broker wants a version between " + feature.minSupportedVersion() + " and " +
feature.maxSupportedVersion() + ", inclusive.");
}
finalizedFeatures.get(feature.name()).ifPresent(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is incorrect. If the minVersion is 0, the feature must be set.

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Sep 9, 2024

I pushed a commit which does what the PR description says (skip features with minVersion of 0)...

take a look

[edit: there are probably some unit tests that need to be fixed up]

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@cmccabe thanks for updating this PR. I will verify this patch on 3.9

BrokerRegistrationRequestData.Feature feature = iter.next();
if (feature.minSupportedVersion() == 0) {
feature.setMinSupportedVersion((short) 1);
iter.remove();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about using removeIf?

newData.features().removeIf(feature -> feature.minSupportedVersion() == 0);

@chia7712
Copy link
Copy Markdown
Member

chia7712 commented Sep 9, 2024

Run the transactions_upgrade_test.py, transactions_mixed_versions_test.py, and kraft_upgrade_test.py with this patch and #17084 on my local. all pass.

I will merge it if no failed tests.

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Sep 9, 2024

I did some cleanup and added the removeIf simplification that was suggested

Copy link
Copy Markdown
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@cmccabe : Thanks for the updated PR. A couple of minor comments.

// at versions less than 4, we must set the minimum version for these features
// to 1 rather than 0. See KAFKA-17011 for details.
key.setMinVersion((short) 1);
// at versions less than 4, we must omit these features. See KAFKA-17492.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to change the comment like the following in ApiVersionResponse.json and BrokerRegistrationRequest.json.

Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.

Copy link
Copy Markdown
Member

@chia7712 chia7712 Sep 10, 2024

Choose a reason for hiding this comment

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

@m1a2st Could you please address @junrao comment? That includes following files.

"about": "Features supported by the broker. Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.",

https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/BrokerRegistrationRequest.json#L51

assertEquals(expectedMinVersion, key.minVersion())
}

def assertFeatureMissing(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be private?

@m1a2st
Copy link
Copy Markdown
Collaborator Author

m1a2st commented Sep 10, 2024

Thanks for @cmccabe, @chia7712, @junrao helping for this issue, I will complete this PR

@m1a2st m1a2st marked this pull request as ready for review September 10, 2024 01:19
// at versions less than 4, we must set the minimum version for these features
// to 1 rather than 0. See KAFKA-17011 for details.
key.setMinVersion((short) 1);
// Note: For API versions v0-v3, features with MinSupportedVersion = 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment is not accurate. Could you consider using @cmccabe's comment?

                // Some older clients will have deserialization problems if a feature's
                // minimum supported level is 0. Therefore, when preparing ApiVersionResponse
                // at versions less than 4, we must omit these features. See KAFKA-17492.

@chia7712
Copy link
Copy Markdown
Member

Some older clients will have deserialization problems if a KIP-584 feature's minimum supported
level is 0.  Therefore, when preparing an ApiVersionResponse for a version less than 4, we must
omit features with a minimum supported level of 0. This is reasonable to do because older software
could not handle setting these features to a level other than 0 in any case.

A similar problem applies to BrokerRegistrationRequest. Here we must omit features with minVersion
= 0 when the RPC version is less than 4.

Note that this fix supersedes an earlier compatibility preservation effort in KAFKA-17011.
{ "name": "SupportedFeatures", "type": "[]SupportedFeatureKey", "ignorable": true,
"versions": "3+", "tag": 0, "taggedVersions": "3+",
"about": "Features supported by the broker. Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.",
"about": "Features supported by the broker. Note: in v0-v3, features blocked with MinSupportedVersion = 0.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pardon me, I don't catch "features blocked with MinSupportedVersion = 0."

Also, please fix BrokerRegistrationRequest.json too

Copy link
Copy Markdown
Collaborator Author

@m1a2st m1a2st Sep 10, 2024

Choose a reason for hiding this comment

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

Pardon me, I don't catch "features blocked with MinSupportedVersion = 0."

I change it to omit, it is more accurancy in this case

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@m1a2st thanks for your patch. two minor comments are left. PTAL

},
{ "name": "Features", "type": "[]Feature",
"about": "The features on this broker. Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.", "versions": "0+", "fields": [
"about": "The features on this broker. Note: in v0-v3, features omit with MinSupportedVersion = 0.", "versions": "0+", "fields": [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about "features with MinSupportedVersion = 0 are omitted"?

{ "name": "SupportedFeatures", "type": "[]SupportedFeatureKey", "ignorable": true,
"versions": "3+", "tag": 0, "taggedVersions": "3+",
"about": "Features supported by the broker. Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.",
"about": "Features supported by the broker. Note: in v0-v3, features omit with MinSupportedVersion = 0.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about "features with MinSupportedVersion = 0 are omitted"?

Copy link
Copy Markdown
Contributor

@cmccabe cmccabe left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @m1a2st @junrao @chia7712

@jolshan
Copy link
Copy Markdown
Member

jolshan commented Sep 10, 2024

Thanks folks for fixing this 🙏

Copy link
Copy Markdown
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@m1a2st : Thanks for the updated PR. Just a couple of minor comments.

{ "name": "SupportedFeatures", "type": "[]SupportedFeatureKey", "ignorable": true,
"versions": "3+", "tag": 0, "taggedVersions": "3+",
"about": "Features supported by the broker. Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.",
"about": "Features supported by the broker. Note: in v0-v3, features MinSupportedVersion = 0 are omitted.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

features MinSupportedVersion = 0 are omitted => features with MinSupportedVersion = 0 are omitted

},
{ "name": "Features", "type": "[]Feature",
"about": "The features on this broker. Note: in v0-v3, features with MinSupportedVersion = 0 show up with MinSupportedVersion = 1.", "versions": "0+", "fields": [
"about": "The features on this broker. Note: in v0-v3, features MinSupportedVersion = 0 are omitted.", "versions": "0+", "fields": [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

features MinSupportedVersion = 0 are omitted => features with MinSupportedVersion = 0 are omitted

Copy link
Copy Markdown
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@m1a2st : Thanks for the updated PR. LGTM

@chia7712
Copy link
Copy Markdown
Member

The last commit does not impact source code, so I'm going to merge it to test full e2e with #17084

@chia7712 chia7712 merged commit e311716 into apache:trunk Sep 10, 2024
chia7712 pushed a commit that referenced this pull request Sep 10, 2024
… with 1 when BrokerRegistrationRequest < 4 (#17128)

The 3.8 controller assumes the unknown features have min version = 0, but KAFKA-17011 replace the min=0 by min=1 when BrokerRegistrationRequest < 4. Hence, to support upgrading from 3.8.0 to 3.9, this PR changes the implementation of ApiVersionsResponse (<4) and BrokerRegistrationRequest (<4) to skip features with supported minVersion of 0 instead of replacing 0 with 1

Reviewers: Jun Rao <junrao@gmail.com>, Colin P. McCabe <cmccabe@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
@junrao
Copy link
Copy Markdown
Contributor

junrao commented Sep 10, 2024

@m1a2st : Could we update https://cwiki.apache.org/confluence/display/KAFKA/KIP-1022%3A+Formatting+and+Updating+Features and the mailing list with the changes in this PR?

In order to resolve this dilemma, we will create a new version 4 for ApiVersionsRequest. Clients which send v4 promise to be able to handle ranges including 0. Clients which send v3 will never see a range that starts with 0. Such ranges will be translated into ranges starting with 1 instead.

Similarly, for BrokerRegistrationRequest, we will create a new version 4. Servers which accept v4 promise to be able to handle ranges including 0. Servers which do not will get ranges that only start with 1, rather than 0.

@m1a2st
Copy link
Copy Markdown
Collaborator Author

m1a2st commented Sep 11, 2024

tedyu pushed a commit to tedyu/kafka that referenced this pull request Jan 6, 2025
… with 1 when BrokerRegistrationRequest < 4 (apache#17128)

The 3.8 controller assumes the unknown features have min version = 0, but KAFKA-17011 replace the min=0 by min=1 when BrokerRegistrationRequest < 4. Hence, to support upgrading from 3.8.0 to 3.9, this PR changes the implementation of ApiVersionsResponse (<4) and BrokerRegistrationRequest (<4) to skip features with supported minVersion of 0 instead of replacing 0 with 1

Reviewers: Jun Rao <junrao@gmail.com>, Colin P. McCabe <cmccabe@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants