Skip to content

Conversation

@adixitconfluent
Copy link
Contributor

@adixitconfluent adixitconfluent commented Nov 4, 2025

About

This PR aims to resolve the bug when we have '/' or '+' in memberId
within share fetch and share acknowledge RPCs. The bug arises primarily
because we do a string -> Uuid conversion and vice-versa in the broker
for memberId. When a string containing '/' or '+' is converted to
Uuid, the Base64.getUrlDecoder() is unable to decode the string to a
Uuid and gives an exception which is the reason for the bug.
On analysis, it looks like there is no efficiency added due to this
inter-conversion. Hence, we have gotten rid of the conversion from
string -> Uuid in KafkaApis for memberId. Thus, everywhere on the
broker memberId always treated as string not a Uuid

While fixing this, I noticed that we don't need mapping in
ShareSessionContext class, hence removed it.

Testing

Added a few unit tests to validate the new functionality

@github-actions github-actions bot added triage PRs from the community core Kafka Broker KIP-932 Queues for Kafka labels Nov 4, 2025
@adixitconfluent adixitconfluent marked this pull request as ready for review November 4, 2025 06:57
@AndrewJSchofield AndrewJSchofield removed the triage PRs from the community label Nov 4, 2025
@AndrewJSchofield AndrewJSchofield self-requested a review November 4, 2025 11:57
Copy link
Member

@AndrewJSchofield AndrewJSchofield 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. Overall looks good, but I do have one high-level comment about validation and special values for the member ID.

val shareFetchData = shareFetchRequest.shareFetchData(topicIdNames)
val forgottenTopics = shareFetchRequest.forgottenTopics(topicIdNames)

val newReqMetadata: ShareRequestMetadata = new ShareRequestMetadata(Uuid.fromString(memberId), shareSessionEpoch)
Copy link
Member

Choose a reason for hiding this comment

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

The tricky thing here is that previously we expected the member ID to be a UUID formatted in the way that the Kafka Java class does it. But, the RPCs define it as a string and there's no need for it to be formatted in that way, provided it's unique across the clients. We should validate the incoming member ID string to ensure that it's non-zero in length, and that it's length does not extend beyond the length of a human-readable UUID (36 characters).

Also, we use AAAAAAAAAAAAAAAAAAAAAAAA as the comparison value for no member ID, so that's a bad choice too. We could change the comparison value for no member ID to the empty string "", which the validation above would reject for use as a member ID, and then it would be permissible (but ill-advised) to use AAAAAAAAAAAAAAAAAAAAAAAA as the member ID, just because that's a well-known value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed and done

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.

Can you please help me understand regrading why we do not want the ShareRequestMetadata in the calls i.e. why do we need that chnage? I was expecting the non-uuid conversion of string, just only some validations as @AndrewJSchofield suggested.

Comment on lines -42 to -48
/**
* Returns true if this is a full share fetch request.
*/
public boolean isFull() {
return (this.epoch == INITIAL_EPOCH) || (this.epoch == FINAL_EPOCH);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function was only utilized within the broker, hence I've removed this functionality from this class and added it to SharePartitionManager.java

/**
* The member ID.
*/
private final Uuid memberId;
Copy link
Contributor

Choose a reason for hiding this comment

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

I was expecting a change here rather than removing the usage of ShareRequestMetadata

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ShareRequestMetadata is utilized in the client at multiple places such as ShareFetchRequest.java, ShareSessionHandler.java and ShareAcknowledgeRequest.java because memberId is treated as Uuid there, hence I did not touch this class. Besides, all the functionalities of ShareRequestMetadata that are utilized in the broker are static in nature, hence I got rid of it in the broker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved clients core Kafka Broker KIP-932 Queues for Kafka

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants