Skip to content

Partition consumer hangs when reading messages from beginning of compacted topic #1782

Description

@akamensky
Versions
Sarama Kafka Go
1.27.2 2.6.0 1.15.4
Configuration

What configuration values are you using for Sarama and Kafka?

	// Common settings
	config := sarama.NewConfig()
	config.Version = sarama.V2_6_0_0
	config.ClientID = "ksnap"

	// Consumer settings
	config.Consumer.Offsets.AutoCommit.Enable = false
	config.Consumer.Offsets.Initial = sarama.OffsetOldest
Logs
logs: CLICK ME

The log below is a log output as seen when enabling logging in Sarama. It hangs at the last line and keeps doing-nothing indefinitely.

[Sarama] 2020/08/19 14:40:37 Initializing new client
[Sarama] 2020/08/19 14:40:37 client/metadata fetching metadata for all topics from broker kafka04:9092
[Sarama] 2020/08/19 14:40:37 Connected to broker at kafka04:9092 (unregistered)
[Sarama] 2020/08/19 14:40:37 client/brokers registered new broker #5 at kafka05:9092
[Sarama] 2020/08/19 14:40:37 client/brokers registered new broker #4 at kafka04:9092
[Sarama] 2020/08/19 14:40:37 client/brokers registered new broker #6 at kafka06:9092
[Sarama] 2020/08/19 14:40:37 client/brokers registered new broker #2 at kafka02:9092
[Sarama] 2020/08/19 14:40:37 client/brokers registered new broker #3 at kafka03:9092
[Sarama] 2020/08/19 14:40:37 Successfully initialized new client
[Sarama] 2020/08/19 14:40:37 Connected to broker at kafka03:9092 (registered as #3)
[Sarama] 2020/08/19 14:40:37 consumer/broker/3 added subscription to TopicName/0

Code

https://github.com/EclipseTrading/ksnap

Problem Description

We are using sarama to read messages from beginning of partition until last message, most topics work fine, but we have a set of topics which are being republished every morning (compact topics with unique keys, keys being republished every morning to overwrite values). These topics always (every time) hang on reading very first message. I've ran a debugger and inspected the routines -- the one that i found appears to wait indefinitely for response from server (which may or may not have arrived already, as I could not see that in debugger).

We have two other applications reading from this topic (one in Java using standard client and one in C++ using librdkafka), both applications have no problems of consuming this partition from the very first offset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-investigationIssues that require followup from maintainersstale/exemptIssues and pull requests that should never be closed as stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions