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

chore(block-builder): update block builder to use kafka clients directly #15433

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

Conversation

ashwanthgoli
Copy link
Contributor

What this PR does / why we need it:

Currently block builders create ephemeral partition reader for processing a new job, but this fails to work as expected because of duplicate kprom metric registration that is triggered on new client creation. We could get around this by wrapping the registerer with partition_id and worker_id labels and carefully deregistering them when the job processing is complete.

But at this point of time, I prefer directly using the kafka clients (one per each block builder worker) which offers better control over addition/removal of partitions to consume. We can look into partition reader refactor down the line if it's neccessary.

This pr updates block builder to use direct kafka clients, one client per worker. We add partition consume offset when we start a job and remove it at the end of the job to allow reusing the same client.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@ashwanthgoli ashwanthgoli changed the title chore(block-builder): refactor blockbuilder to use kafka clients directly chore(block-builder): update block builder to use kafka clients directly Dec 17, 2024
@ashwanthgoli ashwanthgoli marked this pull request as ready for review December 17, 2024 05:46
@ashwanthgoli ashwanthgoli requested a review from a team as a code owner December 17, 2024 05:46
pkg/blockbuilder/builder/builder.go Outdated Show resolved Hide resolved
// No more records available
break
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this continue instead of break? And do we want to reset the backoff after a successful poll first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is unlikely, but if we are already caught-up to the latest produced offset this should allow a few retries before failing. I don't have a strong opinion about this change

}

// Reset backoff on successful poll
boff.Reset()

converted := make([]AppendInput, 0, len(records))
for _, record := range records {
converted := make([]AppendInput, 0, fs.NumRecords())
Copy link
Contributor

Choose a reason for hiding this comment

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

Comparing to the existing partition reader, would it be useful to add some metrics on number of records processed etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

definitely! i'll take that in a follow-up :)

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

Successfully merging this pull request may close these issues.

3 participants