Skip to content

KAFKA-10000: Add producer fencing API to admin client (KIP-618)#11777

Merged
tombentley merged 4 commits intoapache:trunkfrom
C0urante:kafka-10000-admin-client
Mar 3, 2022
Merged

KAFKA-10000: Add producer fencing API to admin client (KIP-618)#11777
tombentley merged 4 commits intoapache:trunkfrom
C0urante:kafka-10000-admin-client

Conversation

@C0urante
Copy link
Copy Markdown
Contributor

Implements the new admin client API described in KIP-618.

Note that this API is not used by the Connect framework in this PR. It will be leveraged by Connect in downstream PRs.

Copy link
Copy Markdown
Member

@showuon showuon left a comment

Choose a reason for hiding this comment

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

@C0urante , I've made a pass. Left some comments. Thanks.

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.

There's also an expected error: PRODUCER_FENCED which should be handled here.

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 shouldn't happen if we don't include a producer epoch/ID in the InitProducerIdRequest, right? If so, I could see there still being a case for adding coverage for PRODUCER_FENCED just in order to provide a better user-facing error message, but it's unclear what else we could really say beyond "unexpected error."

Thoughts?

Copy link
Copy Markdown
Member

@showuon showuon Feb 25, 2022

Choose a reason for hiding this comment

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

I agree with you that since we always sent without producerID and epoch, the error should never happen. But I think there might be someone to extend the existing FenceProducerHandler for other purpose, the assumption will not be true. Or at least, we can add a comment here to mention we skip PRODUCER_FENCED on purpose.

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.

Ah, good point about extensibility. I'd personally opt to just leave a comment (and in fact, remove the existing cases for TRANSACTIONAL_ID_NOT_FOUND and INVALID_PRODUCER_EPOCH, which should also never happen) in order to highlight the fact that, should those errors surface, they are completely unexpected.

If we end up needing to leverage this class somewhere else in the future, those assumptions should still hold unless we also change the InitProducerIdRequest we send to the broker. I can make note of that in another comment in the buildSingleRequest method so that we know to update the error handling logic in that case.

@C0urante
Copy link
Copy Markdown
Contributor Author

Thanks @showuon, appreciate it. I've addressed three of your comments and left a question about the remaining one.

Copy link
Copy Markdown
Member

@showuon showuon 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 PR.

Comment on lines 78 to 81
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.

Looks good.

@showuon
Copy link
Copy Markdown
Member

showuon commented Feb 26, 2022

I'll wait for a while to see if there are other people want to have another review. Thanks.

Comment thread clients/src/main/java/org/apache/kafka/clients/admin/FenceProducersResult.java Outdated
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.

Is it correct to use Object::toString here, rather than Enum::name? If so, maybe the javadoc needs adjusting since it's not guaranteed to return the enum value name.

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.

I opted for toString instead of name since the former can be overridden, but the latter can't. The Javadoc does explicitly link to the toString method, but that's probably not enough to cancel out the assumption people might make that the text "name" refers to Enum::name.

I can tweak it to say "string representations", which is a little clunkier but shouldn't mislead people like "name" might. LMK if you have other thoughts.

Comment thread clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java Outdated
@C0urante C0urante force-pushed the kafka-10000-admin-client branch from 282b559 to 6228d2b Compare March 2, 2022 02:04
@C0urante
Copy link
Copy Markdown
Contributor Author

C0urante commented Mar 2, 2022

Thanks for taking a look, @tombentley. Ready for another pass when you have time.

Copy link
Copy Markdown
Member

@tombentley tombentley 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 @C0urante!

@tombentley
Copy link
Copy Markdown
Member

Merging since failing tests appear to be unrelated.

@tombentley tombentley merged commit 066cdc8 into apache:trunk Mar 3, 2022
@C0urante C0urante deleted the kafka-10000-admin-client branch March 3, 2022 15:40
@C0urante
Copy link
Copy Markdown
Contributor Author

C0urante commented Mar 3, 2022

Thanks Tom!

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.

3 participants