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

kgo sink: do not back off on certain edge case #761

Merged
merged 1 commit into from
Jul 29, 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
20 changes: 20 additions & 0 deletions pkg/kgo/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,24 @@ func (s *sink) handleRetryBatches(
return
}

// If the request failed due to a concurrent metadata update
// moving partitions to a different sink (or killing the sink
// this partition was on), we can just reset the drain index
// and trigger draining now the new sink. There is no reason
// to backoff on this sink nor trigger a metadata update.
if batch.owner.sink != s {
if debug {
logger.Log(LogLevelDebug, "transitioned sinks while a request was inflight, retrying immediately on new sink without backoff",
"topic", batch.owner.topic,
"partition", batch.owner.partition,
"old_sink", s.nodeID,
"new_sink", batch.owner.sink.nodeID,
)
}
batch.owner.resetBatchDrainIdx()
return
}

if canFail || s.cl.cfg.disableIdempotency {
if err := batch.maybeFailErr(&s.cl.cfg); err != nil {
batch.owner.failAllRecords(err)
Expand Down Expand Up @@ -1003,6 +1021,8 @@ func (s *sink) handleRetryBatches(
// If neither of these cases are true, then we entered wanting a
// metadata update, but the batches either were not the first batch, or
// the batches were concurrently failed.
//
// If all partitions are moving, we do not need to backoff nor drain.
if shouldBackoff || (!updateMeta && numRetryBatches != numMoveBatches) {
s.maybeTriggerBackoff(backoffSeq)
s.maybeDrain()
Expand Down
Loading