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

seek_to_committed does not work when committed offset is 0 #1003

Open
t7wakim opened this issue May 2, 2024 · 0 comments
Open

seek_to_committed does not work when committed offset is 0 #1003

t7wakim opened this issue May 2, 2024 · 0 comments

Comments

@t7wakim
Copy link

t7wakim commented May 2, 2024

Hi,

The seek to committed function has a small bug. It does not work when the last committed offset of a TopicPartition is 0 (i.e., nothing was ever committed). This happens if you getmany() or getone() message from a never-committed-to TopicPartition with auto commit disabled. Lets say the messages couldn't be processed and you want to seek_to_committed which is 0 in this case, it doesn't work.

Snippet of code from the seek_to_committed method:

            if offset and offset > 0:
                self._fetcher.seek_to(tp, offset)
        return committed_offsets

I believe the if statement above should be if offset and offset >= 0: which is valid.

To work around this, I had to do the following, which works as expected:

                        current_committed_offset = await consumer.committed(tp)
                        consumer.seek(tp, current_committed_offset)

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant