Skip to content

feat: handle kafka errors that require to refresh metadata #5253

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

javiermolinar
Copy link
Contributor

@javiermolinar javiermolinar commented Jun 10, 2025

What this PR does:
Some Kafka errors require to refresh the client metadata:

error level=erro caller=metrics.go:58 msg="metric lag failed:" err="request ListOffsets has 1 separate shard errors, first: unknown broker"

or

level=error caller=blockbuilder.go:224 msg="consumeCycle failed" err="request ListOffsets has 1 separate shard errors, first: unknown broker"

We want to ensure that the client metadata is not stale and in the case of "unknownBroker" retry the operation. It adds a backoff strategy to handle the retries.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Comment on lines +210 to +212
func() {
b.kafkaClient.ForceMetadataRefresh()
})
Copy link
Contributor

Choose a reason for hiding this comment

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

You can pass the function directly without wrapping it.

Suggested change
func() {
b.kafkaClient.ForceMetadataRefresh()
})
b.kafkaClient.ForceMetadataRefresh

Comment on lines +524 to +533
for boff.Ongoing() {
commits, endsOffsets, err = b.getPartitionOffsets(ctx)
if err == nil {
break
}
retryable := ingest.HandleKafkaError(err, b.kafkaClient.ForceMetadataRefresh)
if retryable {
boff.Wait()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this loop and a similar one in metrics.go, if the error is non-retryable it retries it immediately anyway while the back-off is still ongoing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants