Skip to content

Reader processes stale messages after group rebalance due to undrained internal queue #1398

@Tang8330

Description

@Tang8330

Describe the bug

I've noticed that during a Kafka consumer group rebalance, the Reader does not flush its internal message queue. As a result, messages fetched before the rebalance may still be processed afterward, even if the partition assignment has changed. This could lead to message duplicates (which is fine) and possible ordering violations.

What I am seeing is:

  • We are fetching messages (say 0-100 offset), then we commit offset 100
  • After committing, we go back to fetch message, we can receive a message where its offset is lower than 100 (previously committed)

Kafka Version

Kafka 3.7

  • What version(s) of Kafka are you testing against?
  • What version of kafka-go are you using?

v0.4.47

Heartbeats and session timeouts are all Kafka defaults.

** To reproduce **

I haven't been able to find a way to reproduce this deterministically. Potentially can be triggered by constantly trying to rebalance the Kafka cluster.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions