-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-18659: librdkafka compressed produce fails unless api versions returns produce v0 #18727
base: trunk
Are you sure you want to change the base?
KAFKA-18659: librdkafka compressed produce fails unless api versions returns produce v0 #18727
Conversation
30ea3d7
to
6b145a6
Compare
@@ -208,7 +211,7 @@ public static String toHtml() { | |||
// Responses | |||
b.append("<b>Responses:</b><br>\n"); | |||
Schema[] responses = key.messageType.responseSchemas(); | |||
for (int i = 0; i < responses.length; i++) { | |||
for (int i = oldestVersion; i < responses.length; i++) { |
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.
This bug fix is unrelated to the main change in this PR.
@@ -69,11 +74,6 @@ public ProduceRequest build(short version) { | |||
return build(version, true); | |||
} | |||
|
|||
// Visible for testing only | |||
public ProduceRequest buildUnsafe(short version) { |
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.
This is unused.
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.
It seems we can merge private ProduceRequest build(short version, boolean validate)
into public ProduceRequest build(short version)
. Otherwise, IDE complains the method has a "always true" input variable validate
.
6b145a6
to
6bbf021
Compare
…returns produce v0
6bbf021
to
a252374
Compare
The test failures look related:
Investigating. |
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.
@ijuma thanks for this fix. Does this patch enable Kafka clients to communicate with older servers that support Produce v0-v2? If so, should we disable that request on client-side?
@@ -69,11 +74,6 @@ public ProduceRequest build(short version) { | |||
return build(version, true); | |||
} | |||
|
|||
// Visible for testing only | |||
public ProduceRequest buildUnsafe(short version) { |
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.
It seems we can merge private ProduceRequest build(short version, boolean validate)
into public ProduceRequest build(short version)
. Otherwise, IDE complains the method has a "always true" input variable validate
.
// See `ProduceRequest.MIN_VERSION` for details on why we need to do this | ||
if (produceRequest.version < ProduceRequest.MIN_VERSION) { | ||
requestHelper.sendErrorResponseMaybeThrottle(request, Errors.UNSUPPORTED_VERSION.exception()) | ||
return; |
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.
;
is unnecessary
@chia7712 Good point regarding the client behavior, I'll look into adjusting that too. |
Thinking about it, there is probably a cleaner way to make this change. Let me try that. |
@@ -44,7 +47,7 @@ | |||
// transaction V2 (KIP_890 part 2) is enabled, the produce request will also include the function for a | |||
// AddPartitionsToTxn call. If V2 is disabled, the client can't use produce request version higher than 11 within | |||
// a transaction. | |||
"validVersions": "3-12", | |||
"validVersions": "0-12", |
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.
Instead of bringing back v0 and v1, could we just customize the minVersion of the produce ApiKey in ApiResponse?
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.
I am indeed exploring something involving customizing ApiKey/ApiResponse (that's what I meant when I said that there may be a cleaner way to make the change). But I was planning to leave 0-12 here and reduce the range within the code.
The main advantage is that you get appropriate errors if you try to produce with v0-2. The option you suggest would result in a disconnection. I think a disconnection is too confusing if the given version is included as part of the api versions response.
Thoughts?
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.
It seems that UNSUPPORTED_VERSION
was added in 0.10.0 https://github.com/apache/kafka/pull/986/files#diff-0ae188e241ee35148145e7e04ed2acb3c20356650194f3603811c51b886ebe20. Produce v0/v1 already existed in 0.9. So, even if we send UNSUPPORTED_VERSION
in the error, the 0.9 client won't be able to understand it. So, it really only helps with Produce v2 request.
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.
I agree that it's nearly impossible to make the experience for these super ancient clients good. I was more thinking about client developers implementing the kafka protocol.
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.
Yes, we could make an effort to send a more meaningful error code for produce v0-v2. But since they are not really supported on the broker, just doing a disconnect like any other unsupported version also seems reasonable.
Advertise support for produce v0-v2, but return an UnsupportedVersion error if a produce request with these versions is attempted.
Since clients pick the highest supported version by both client and broker during version negotiation, this solves the problem with minimal tech debt (even though it's not ideal that the protocol definition becomes inconsistent with the actual protocol support). Adjust the protocol html generation to exclude produce v0-v2 and fix an existing bug in the response output where removed versions were not excluded.
Add an integration test to verify the behavior for produce v0-v2.
Reference to related librdkafka issue: confluentinc/librdkafka#4956
Committer Checklist (excluded from commit message)