[Backport 7.81.x] Kafka consumer broker timestamps and earliest offsets caching#24537
Closed
piochelepiotr wants to merge 10 commits into
Closed
[Backport 7.81.x] Kafka consumer broker timestamps and earliest offsets caching#24537piochelepiotr wants to merge 10 commits into
piochelepiotr wants to merge 10 commits into
Conversation
…instead of json Backport of #24471. The DSM broker_timestamps cache was serialized with json.dumps on every check run; at high partition counts this is the dominant allocation source feeding cluster-check-runner memory fragmentation and OOMs (#incident-57455). Persist with marshal (base64-wrapped) instead: a compact binary codec that avoids JSON's per-number text encoding, cutting serialization ~100x on the save path, with no change to emitted metrics. Unlike pickle, marshal cannot deserialize into code execution. On-disk format changes and is version-specific, so an older cache is discarded once and rebuilt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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> (cherry picked from commit e2fa09e)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 80292d3)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> (cherry picked from commit 491f476)
…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> (cherry picked from commit 3150cf3)
The changelog filename embeds the originating PR number; this backport needs its own entry once its PR is opened, not the master PR's number. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…st-offsets caching Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 50e77c7 | Docs | Datadog PR Page | Give us feedback! |
Contributor
Validation ReportAll 21 validations passed. Show details
|
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?
Backports six kafka_consumer changes to the
7.81.xbranch:marshalinstead of JSON, to reduce cluster-check-runner memory churn.broker_timestampshistory per cluster by a per-partition budget derived fromMAX_TIMESTAMP_ENTRIES, so memory use no longer grows unbounded with partition count.AdminClientandConsumeracross runs (defaultclose_admin_clientto false, idempotentopen_consumer, stop closing the cluster-id consumer) so per-broker threads and their glibc arenas persist and their memory is recycled in place instead of stranded each run.malloc_trim(0)after each run (glibc/Linux only) to return per-arena free memory to the OS.broker_timestampscache in memory across runs and persist it to disk at most every 5 minutes, removing the per-run marshal load/dump churn that scaled with cache size.The #24508 and #24515 changes were adapted during the backport: #24508 was built on master's newer bulk-pruning
_add_broker_timestamps(withprune_floors/_visvalingam_whyatt), so it was reimplemented on top of the 7.81.x branch's older single-oldest-eviction logic while preserving the same budget-scaling behavior. #24515's publicfetch_earliest_offsetsmethod was kept as the 7.81.x branch's existing private_fetch_earliest_offsetsname to avoid an unrelated naming change.Motivation
Bring memory-usage and caching improvements already merged/in review on
masterto the7.81.xrelease branch.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