From f94b482ee9a302191d11bfdd1fc027a2aacb8e62 Mon Sep 17 00:00:00 2001 From: Matthew Wang Date: Fri, 23 Oct 2015 16:31:34 +0800 Subject: [PATCH] Reset offset to :earliest_offset whenever OffsetOutOfRange happens OffsetOutOfRange error can also happen when the returned offset is a positive number but corresponding messages started from the offset were retentioned --- lib/poseidon/partition_consumer.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/poseidon/partition_consumer.rb b/lib/poseidon/partition_consumer.rb index d90a64c..e585582 100644 --- a/lib/poseidon/partition_consumer.rb +++ b/lib/poseidon/partition_consumer.rb @@ -112,8 +112,7 @@ def fetch(options = {}) partition_response = topic_response.partition_fetch_responses.first unless partition_response.error == Errors::NO_ERROR_CODE - if @offset < 0 && - Errors::ERROR_CODES[partition_response.error] == Errors::OffsetOutOfRange + if Errors::ERROR_CODES[partition_response.error] == Errors::OffsetOutOfRange @offset = :earliest_offset return fetch(options) end