Skip to content

fix(kafka): Read from beginning if no committed offset - #14865

Merged
benclive merged 1 commit into
mainfrom
start-from-beginning-if-no-commit
Nov 12, 2024
Merged

benclive merged 1 commit into
mainfrom
start-from-beginning-if-no-commit

Conversation

@benclive

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
If there is no offset for a consumer group & partition, kafka returns -1 which is a special offset for "latest". I am remapping this to -2, which means replay from the start. By using -1, we would start consuming from the latest offset instead of replaying older data in the case where we start a new consumer group, and therefore the latest data would unavailable.

I don't know if this affects environments with long-lived partition-ingesters, but if kafka expires or cleans up a consumer group after some time, we might trigger this on scale up to new partitions and the latest data would be unavailable.

@benclive
benclive requested a review from a team as a code owner November 11, 2024 18:13

@cyriltovena cyriltovena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@benclive
benclive merged commit 1b6da11 into main Nov 12, 2024
@benclive
benclive deleted the start-from-beginning-if-no-commit branch November 12, 2024 14:06
felix0102 pushed a commit to felix0102/loki that referenced this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants