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

Discard messages with a lower offset than requested #100

Merged
merged 2 commits into from
Jul 31, 2018

Conversation

tulios
Copy link
Owner

@tulios tulios commented Jul 30, 2018

Fetch can return message sets with a lower offset than the requested, for example, we fetch data from offset 77 but receive a message set starting with offset 51. This behavior happens due to how Kafka stores the message sets on disk. When seeking to different offsets than the natural flow (from the beginning or the end), it can lead to "wrong" batches.

@tulios tulios requested a review from Nevon July 30, 2018 22:17
@@ -3,9 +3,27 @@ const Batch = require('../batch')
describe('Consumer > Batch', () => {
const topic = 'topic-name'

it('discards messages with a lower offset than the requested', () => {
const fetchedOffset = 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not that it matters for these cases, but shouldn't fetchedOffset always be a string?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Everything will be converted into a long so, technically yes, but in the end it doesn't matter that much. Numbers highlight better in the test

@tulios tulios merged commit 1928339 into master Jul 31, 2018
@tulios tulios deleted the discard-messages-with-a-lower-offset-than-requested branch September 25, 2018 17:57
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

Successfully merging this pull request may close these issues.

2 participants