Skip to content

Consumer get stucked in compacted topic #555

Closed
@Elyahou

Description

@Elyahou

When replaying a compacted topic, with 20 partitions, the consumer get stucked in 5 partitions at some offsets, and don't succeed to read any more messages. All the other partitions were successully replayed...

I succeeded to fix this by manually increasing the consumer group offset for the problematic partitions, after I saw that it was stucked in an offset that was compacted and there was no messages for it in kafka.

Example:

offset status remark
1 read message present
2 read message present
3 read message present
4 stucked here deleted by kafka compaction
5 deleted by kafka compaction
6 deleted by kafka compaction
7 message present

So it works only after I moved the offset of the consumer group to 7.

Some remarks:

  • There is other offsets that was compacted by kafka and there was no issue there
  • The kafka console consumer succeeded to consume these messages continuously without any issue
  • I tried all kind of configuration changes on socket_timeout, connect_timeout and max_wait_time., but it did not help.
  • Version of Ruby: 2.3.5
  • Version of Kafka: 0.11.0.2
  • Version of ruby-kafka: 0.5.4
Code of the consumer
require "kafka"

kafka = Kafka.new(["kafka1:9092", "kafka2:9092"])
consumer = kafka.consumer(group_id: "my-consumer")
consumer.subscribe("greetings")
trap("TERM") { consumer.stop }

consumer.each_message do |message|
  puts message.topic, message.partition
  puts message.offset, message.key, message.value
end

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions