Skip to content
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-18022: fetchOffsetMetadata handling for minBytes estimation in both common/uncommon cases of share fetch #17825

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

adixitconfluent
Copy link
Contributor

About

In reference to comments #17539 (comment) and #17739 (comment), I have updated the way we handle fetchOffsetMetadata update and get so that minBytes estimation is consistent for both common and uncommon cases of share fetch.

Testing

Testing has been done with the help of new/already present unit tests and already present integration tests.

@github-actions github-actions bot added core Kafka Broker KIP-932 Queues for Kafka small Small PRs labels Nov 15, 2024
Copy link
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.

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

* FetchOffsetMetadata class is used to cache offset and its log metadata.
*/
static final class OffsetMetadata {
private long offset;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's useful to add a comment that this offset could be different from offsetMetadata.messageOffset if it's in the middle of a batch.

private LogOffsetMetadata offsetMetadata;

OffsetMetadata() {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we initialize the fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if initializing the fields has any benefits. The only value initialization inside the constructor that makes sense is offset=-1 i.e. an invalid case. We don't really need this initialization since we can use offsetMetadata() == null to check if the object fetchOffsetMetadata has been cached yet or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, since 0 is a valid offset, it's better to initialize offset to -1.

Copy link
Contributor Author

@adixitconfluent adixitconfluent Nov 15, 2024

Choose a reason for hiding this comment

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

i've pushed the change in my latest commit. Thanks!

@adixitconfluent
Copy link
Contributor Author

Hi @junrao , I have pushed the suggested change. Please review this PR when you get a chance. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved core Kafka Broker KIP-932 Queues for Kafka small Small PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants