Skip to content

KAFKA-19485: Added check before sending acknowledgements on initial epoch. #20135

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

Merged
merged 3 commits into from
Jul 10, 2025

Conversation

ShivsundarR
Copy link
Collaborator

@ShivsundarR ShivsundarR commented Jul 9, 2025

https://issues.apache.org/jira/browse/KAFKA-19485

Bug :
There is a bug in ShareConsumeRequestManager where we are adding
acknowledgements on initial ShareSession epoch even after checking for
it.
Added fix to only include acknowledgements in the request if we have to,

PR also adds the check at another point in the code where we could
potentially be sending such acknowledgements. One of the cases could be
when metadata is refreshed with empty topic IDs after a broker restart.
This means leader information would not be available on the node.

  • Consumer subscribed to a partition whose leader was node-0.
  • Broker restart happens and node-0 is elected leader again. Broker
    starts a new ShareSession.
  • Background thread sends a fetch request with non-zero epoch.
  • Broker responds with SHARE_SESSION_NOT_FOUND.
  • Client updates session epoch to 0 once it receives this error.
  • Client updates metadata but receives empty metadata response. (Leader
    unavailable)
  • Application thread processing the previous fetch, completes and sends
    acks to piggyback on next fetch.
  • Next fetch will send the piggyback acknowledgements on the fetch for
    previously subscribed partitions resulting in error from broker
    ("Acknowledge data present on initial epoch"). (Currently we attempt
    to send even if leader is unavailable).

Fix : Add a check before sending out acknowledgments if we are on
an initial epoch.
Added unit test covering the above scenario.

Reviewers: Andrew Schofield [email protected]

@github-actions github-actions bot added triage PRs from the community consumer clients small Small PRs labels Jul 9, 2025
@ShivsundarR ShivsundarR added KIP-932 Queues for Kafka ci-approved labels Jul 9, 2025
@AndrewJSchofield AndrewJSchofield removed the triage PRs from the community label Jul 9, 2025
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.

@AndrewJSchofield AndrewJSchofield merged commit 56a3c6d into apache:trunk Jul 10, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants