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

How to handle offsetOutOfRange error #408

Closed
nedstarksbastard opened this issue Jul 20, 2016 · 1 comment
Closed

How to handle offsetOutOfRange error #408

nedstarksbastard opened this issue Jul 20, 2016 · 1 comment

Comments

@nedstarksbastard
Copy link

I am running a node server that acts as a Kafka Consumer. I had seen instances of few offsetOutOfRange errors online, whereby the consumer tries to read messages that are no longer available. I tried to overcome that by having the following handler

consumer.on('offsetOutOfRange', function (topic) {
        console.log("------------- offsetOutOfRange ------------");
        topic.maxNum = 2;
        offset.fetch([topic], function (err, offsets) {
            var min = Math.min.apply(null, offsets[topic.topic][topic.partition]);
            consumer.setOffset(topic.topic, topic.partition, min);
        });
});

I am still not able to absolve this issue. I get the offsetOutOfRange issue in a continuous loop. But amazingly I am also getting all the messages generated out of kafka. Does anyone have a clue as to what is happening and how to solve it so that I dont get into this code block. I thought the consumer.setOffset(topic.topic, topic.partition, min); should be able to set the correct offset but that is not the case.

@Foo42
Copy link

Foo42 commented Sep 8, 2016

We were experiencing the same loop and diagnosed the issue to be a type mismatch between the offset numbers returned from zookeeper and those in the payloads list (number in payloads, string from zookeeper). We were preparing a pull request and then noticed it had been fixed in 2747d7c

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

3 participants