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-18494-2: Bugfix in sharePartition. Added gapsAfterInitialization that store the first offsets of all gaps during share partition initialization #18677

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

chirag-wadhwa5
Copy link
Contributor

Bug -> there are times during share partition initialization, where the persister read state response contains batches, eg -
startOffset = 10, stateBatches = {{15, 20}, {30, 40}}
These gaps could natural gaps, but could also be batches which were fetched before but were not acknowledged. In that case, these records must be made available again for fetch.

This PR introduces another class variable, gapsAfterInitialization, which stores the first offset of all these gaps in the read state response. The nextFetchOffset method then consider these gaps as well while finding the next offset to fetch from.

@github-actions github-actions bot added triage PRs from the community core Kafka Broker KIP-932 Queues for Kafka labels Jan 23, 2025
* This maintains the set of gaps in the cachedState after initialization. Some of these gaps might correspond to batches
* which were fetched but not acknowledged yet. The gaps are used in determining the next fetch offset.
*/
private final TreeSet<Long> gapsAfterInitialization;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is TreeSet necessary (lg(n) time data structure).
You are assured that the readState reponse will always be sorted on the intervals - the order is
firstOffset, lastOffset, deliveryCount, deliveryState

@github-actions github-actions bot removed the triage PRs from the community label Jan 24, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants