Skip to content

Commit e0da111

Browse files
authored
Merge pull request #482 from zendesk/dasch/fix-zero-timestamp
Ignore invalid message timestamps
2 parents b5b3c55 + c3951ea commit e0da111

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/kafka/protocol/message.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ def self.decode(decoder)
8989
timestamp = nil
9090
when 1
9191
timestamp = message_decoder.int64
92+
93+
# If the timestamp is set to zero, it's because the message has been upgraded
94+
# from the Kafka 0.9 disk format to the Kafka 0.10 format. The former didn't
95+
# have a timestamp attribute, so we'll just set the timestamp to nil.
96+
timestamp = nil if timestamp.zero?
9297
else
9398
raise Kafka::Error, "Invalid magic byte: #{magic_byte}"
9499
end

0 commit comments

Comments
 (0)