kafka_consumer: cache earliest offsets across collection intervals#24515
Merged
piochelepiotr merged 4 commits intoJul 15, 2026
Merged
Conversation
Log start offsets only move via the broker's log-cleaner cycle (log.retention.check.interval.ms), so refetching them on every check run is unnecessary broker load. Cache the result with a TTL derived from that broker config, clamped to a sane range. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 491f476b33
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 3150cf3 | Docs | Datadog PR Page | Give us feedback! |
…sing partitions on a fresh cache log.retention.check.interval.ms is now read from broker config data purely to derive the earliest-offsets cache TTL, without being added to the metric emission list. fetch_earliest_offsets also now refetches from the broker when a fresh cache doesn't cover every requested partition (e.g. newly added partitions), while keeping the cache's original expiration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3 tasks
rkaneriya
approved these changes
Jul 13, 2026
steveny91
approved these changes
Jul 15, 2026
piochelepiotr
deleted the
piotr.wolski/kafka-consumer-cache-earliest-offsets
branch
July 15, 2026 21:25
|
Backport evaluation: View Slack thread |
3 tasks
Contributor
Validation ReportAll 21 validations passed. Show details
|
nubtron
pushed a commit
that referenced
this pull request
Jul 17, 2026
…24515) (#24575) * kafka_consumer: cache earliest offsets across collection intervals Log start offsets only move via the broker's log-cleaner cycle (log.retention.check.interval.ms), so refetching them on every check run is unnecessary broker load. Cache the result with a TTL derived from that broker config, clamped to a sane range. * Add changelog entry * kafka_consumer: trim redundant comments, add earliest-offsets cache test * Address review feedback: avoid an undocumented metric and refetch missing partitions on a fresh cache log.retention.check.interval.ms is now read from broker config data purely to derive the earliest-offsets cache TTL, without being added to the metric emission list. fetch_earliest_offsets also now refetches from the broker when a fresh cache doesn't cover every requested partition (e.g. newly added partitions), while keeping the cache's original expiration. --------- (cherry picked from commit 7be739d) Co-authored-by: Piotr WOLSKI <piotr.wolski42@gmail.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Caches the per-partition earliest (log-start) offset used to compute
kafka.topic.sizeandkafka.partition.size, instead of refetching it from the broker on every collection interval. The cache TTL is derived from the broker'slog.retention.check.interval.msconfig when available, clamped to[60s, 1800s], defaulting to 300s.Motivation
The earliest offset only moves forward via the broker's log-cleaner cycle, so refetching it every check run adds unnecessary
ListOffsetsload on the broker without the value ever changing between cleaner cycles. Caching it across runs, with a TTL tied to that cycle, removes that redundant load while keeping the reported values accurate.Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged