Skip to content

KAFKA-10729: Bump remaining RPC's to use tagged fields.#9601

Merged
hachikuji merged 10 commits intoapache:trunkfrom
gardnervickers:list-offset-flex-versions
Dec 1, 2020
Merged

KAFKA-10729: Bump remaining RPC's to use tagged fields.#9601
hachikuji merged 10 commits intoapache:trunkfrom
gardnervickers:list-offset-flex-versions

Conversation

@gardnervickers
Copy link
Copy Markdown
Contributor

@gardnervickers gardnervickers commented Nov 16, 2020

As a follow-up from KIP-482, this PR bumps the version for several
RPC's to enable tagged fields via the flexible versioning mechanism.

Additionally, a new IBP version KAFKA_2_8_IV0 is introduced to
allow replication to take advantage of these new RPC versions for
OffsetForLeaderEpoch and ListOffset.

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.

2.7 has been branched. It should be 2.8, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that makes more sense.

@gardnervickers gardnervickers force-pushed the list-offset-flex-versions branch from 10bc65b to 1488283 Compare November 17, 2020 01:06
As a follow-up from KIP-482, this PR bumps the version for several
RPC's to enable tagged fields via the flexible versioning mechanism.

Additionally, a new IBP version `KAFKA_2_7_IV3` is introduced to
allow replication to take advantage of these new RPC versions for
OffsetForLeaderEpoch and ListOffset.
@gardnervickers gardnervickers force-pushed the list-offset-flex-versions branch from 1488283 to fb11509 Compare November 17, 2020 01:09
@gardnervickers gardnervickers changed the title MINOR: Enable flexible versioning for ListOffsetRequest/ListOffsetResponse. KAFKA-10729: Bump remaining RPC's to use tagged fields. Nov 17, 2020
@gardnervickers
Copy link
Copy Markdown
Contributor Author

gardnervickers commented Nov 18, 2020

OffsetForLeaderEpoch and Produce are not yet generated RPCs, but will be once #9401 and #9547 are merged. I've removed the taggedFields bump for these RPC's. We can bump them once their respective PR's are merged.

@gardnervickers gardnervickers force-pushed the list-offset-flex-versions branch from fe69332 to 31f53b4 Compare November 18, 2020 18:58
OffsetForLeaderEpoch and Produce are not yet generated RPCs, but will be once apache#9401 and apache#9547 are merged.
@gardnervickers gardnervickers force-pushed the list-offset-flex-versions branch from 31f53b4 to b836a3d Compare November 18, 2020 18:59
@dajac
Copy link
Copy Markdown
Member

dajac commented Nov 19, 2020

@gardnervickers #9401 and #9547 have been merged. You can bring them back in this PR if you like.

// Introduced AlterIsr (KIP-497)
KAFKA_2_7_IV2
KAFKA_2_7_IV2,
// Flexible versioning on ListOffsets
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.

For what it's worth, WriteTxnMarkers and OffsetsForLeaderEpoch are also inter-broker APIs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to fix testThrottlingNotEnabledForConnectionToOlderBroker. The test forces ApiVersionsResponse to version 5, but relied on the fact that nothing really changed between version 5 and version 8 for PRODUCE responses. With flex versions we need to ensure the response matches the ApiVersions response

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having this override seemed a bit error prone, and was causing failures for the NetworkClientTest. I opted to remove it entirely in favor of forcing the caller to specify the response version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Admittedly I'm not sure why we check the version of the last OffsetForLeaderEpoch response is 3 here. I decided to widen the check a bit so this won't break for future versions.

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.

I think this was originally using 1 in order to ensure that we were using a version which included the epoch in the response. Since then it looks like it has been updated blindly every time we've bumped the protocol. I'm ok leaving this as is, but we could probably also get rid of it.

- NetworkClientTest.testThrottlingNotEnabledForConnectionToOlderBroker was relying on the
  latest PRODUCE version being unchanged from version 5. Fix this by supplying the version
  when constructing the throttled produce response.
- Fixed AlterReplicaLogDirsResponse to take the version in the constructor instead of offering
  an override which assumes that the most recent version is in use. This fixes the NetworkClientTest.
- Fixed ReplicaFetcherThreadTest.shouldFetchLeaderEpochSecondTimeIfLeaderRepliesWithEpochNotKnownToFollower
  to check that the lastUsedOffsetForLeaderEpochVersion is >= 3 instead of == 3. It seems this check is mostly
  in place to ensure that a OffsetForLeaderEpoch response was sent.
@gardnervickers gardnervickers force-pushed the list-offset-flex-versions branch from bb5f2d5 to 7a7d5fd Compare November 29, 2020 21:27
case 6:
case 7:
case 8:
case 9:
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.

I wonder if we may as well make this the default case. Not sure we're getting much by forcing ourselves to update this logic after each bump. Maybe the range validation is still useful, but that could be done by using oldestVersion and latestVersion.

public Builder(final List<TxnMarkerEntry> markers) {
super(ApiKeys.WRITE_TXN_MARKERS);
public Builder(final List<TxnMarkerEntry> markers, short latestAllowedVersion) {
super(ApiKeys.WRITE_TXN_MARKERS, ApiKeys.WRITE_TXN_MARKERS.oldestVersion(), latestAllowedVersion);
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.

I think this is probably ok, but it is a little inconsistent with how we handle the versions for other inter-broker RPCs. Since we rely on the IBP, we always set the version explicitly in the caller, which means there is exactly one allowable version for the builder to use. See for example LeaderAndIsrRequest.Builder.

4 /* correlation id */ +
Type.NULLABLE_STRING.sizeOf(clientId) /* client id */
Type.NULLABLE_STRING.sizeOf(clientId) /* client id */ +
(if (flexVersion) ByteUtils.sizeOfUnsignedVarint(0) else 0)
Copy link
Copy Markdown
Contributor

@hachikuji hachikuji Dec 1, 2020

Choose a reason for hiding this comment

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

nit: maybe add a comment that this field is for the number of tagged fields?

- Make the most recent record batch version the default case when selecting a
  record batch version. Check that the version is within the existing version bounds.
- Force a specific version in the WriteTxnMarkersRequest constructor to match other
  requests which utilize the IBP like LeaderAndISR.
Copy link
Copy Markdown
Contributor

@hachikuji hachikuji 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 for the patch!

@hachikuji hachikuji merged commit 85f94d5 into apache:trunk Dec 1, 2020
ijuma added a commit to ijuma/kafka that referenced this pull request Dec 2, 2020
…t-for-generated-requests

* apache-github/trunk:
KAFKA-9263 The new hw is added to incorrect log when
ReplicaAlterLogDirsThread is replacing log (fix
PlaintextAdminIntegrationTest.testAlterReplicaLogDirs) (apache#9423)
  KAFKA-10729; Bump remaining RPC's to use tagged fields. (apache#9601)

clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java
clients/src/main/java/org/apache/kafka/common/requests/AlterReplicaLogDirsResponse.java
clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java
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.

4 participants