Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/kgo: re-add fetch-canceled partitions AFTER the user callback #737

Merged
merged 1 commit into from
May 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pkg/kgo/consumer_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,6 @@ func (g *groupConsumer) setupAssignedAndHeartbeat() (string, error) {
fetchDone := make(chan struct{})
defer func() { <-fetchDone }()

// If cooperative consuming, we may have to resume fetches. See the
// comment on adjustCooperativeFetchOffsets.
if g.cooperative.Load() {
added = g.adjustCooperativeFetchOffsets(added, lost)
}

// Before we fetch offsets, we wait for the user's onAssign callback to
// be done. This ensures a few things:
//
Expand All @@ -883,6 +877,18 @@ func (g *groupConsumer) setupAssignedAndHeartbeat() (string, error) {
// necessarily run onRevoke before returning (because of a fatal
// error).
s.assign(g, added)

// If cooperative consuming, we may have to resume fetches. See the
// comment on adjustCooperativeFetchOffsets.
//
// We do this AFTER the user's callback. If we add more partitions
// to `added` that are from a previously canceled fetch, we do NOT
// want to pass those fetch-resumed partitions to the user callback
// again. See #705.
if g.cooperative.Load() {
added = g.adjustCooperativeFetchOffsets(added, lost)
}

<-s.assignDone

if len(added) > 0 {
Expand Down
Loading