Skip to content

[Backport 7.81.x] Kafka consumer broker timestamps and earliest offsets caching#24537

Closed
piochelepiotr wants to merge 10 commits into
7.81.xfrom
piotr.wolski/backport-broker-timestamps-marshal-7.81.x
Closed

[Backport 7.81.x] Kafka consumer broker timestamps and earliest offsets caching#24537
piochelepiotr wants to merge 10 commits into
7.81.xfrom
piotr.wolski/backport-broker-timestamps-marshal-7.81.x

Conversation

@piochelepiotr

@piochelepiotr piochelepiotr commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Backports six kafka_consumer changes to the 7.81.x branch:

The #24508 and #24515 changes were adapted during the backport: #24508 was built on master's newer bulk-pruning _add_broker_timestamps (with prune_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 public fetch_earliest_offsets method was kept as the 7.81.x branch's existing private _fetch_earliest_offsets name to avoid an unrelated naming change.

Motivation

Bring memory-usage and caching improvements already merged/in review on master to the 7.81.x release branch.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

piochelepiotr and others added 8 commits July 9, 2026 15:01
…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>
… by a per-cluster memory budget (#24508)

Backports the per-partition history scaling introduced in #24508, adapted to
this branch's simpler single-entry eviction (no visvalingam_whyatt/prune_floor,
which haven't been backported here).

Co-Authored-By: Claude Sonnet 5 <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>
@piochelepiotr piochelepiotr added the qa/skip-qa Automatically skip this PR for the next QA label Jul 13, 2026
…st-offsets caching

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 85.53%
Overall Coverage: 88.46%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 50e77c7 | Docs | Datadog PR Page | Give us feedback!

Backports three additional kafka_consumer memory fixes to 7.81.x:
- #24552: reuse the AdminClient and Consumer across runs
- #24553: malloc_trim after each run
- #24554: keep broker_timestamps in memory, persist every 5 min

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration/kafka_consumer qa/skip-qa Automatically skip this PR for the next QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant