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

Fix broken error handling around Idempotent producer + Ensure strict ordering when Net.MaxOpenRequests = 1 #2943

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
improve error logging
  • Loading branch information
richardartoul committed Jul 20, 2024
commit 1125d60679719cf757d97c50b53441b0a168711b
10 changes: 10 additions & 0 deletions async_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ func (pe ProducerError) Unwrap() error {
type ProducerErrors []*ProducerError

func (pe ProducerErrors) Error() string {
if len(pe) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this ever actually be produced with zero messages?

If it’s unlikely to ever happen with len(pe) == 0 then that should be the guard condition, and then the complex error message should be the unindented path.

return fmt.Sprintf(
"kafka: Failed to deliver %d messages, sample error: %v after %d retries on topic: %s and partition: %d",
len(pe),
pe[0].Err,
pe[0].Msg.retries,
pe[0].Msg.Topic,
pe[0].Msg.Partition,
)
}
return fmt.Sprintf("kafka: Failed to deliver %d messages.", len(pe))
}

Expand Down