Skip to content

Conversation

@dimitarvdimitrov
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov commented Oct 17, 2025

Draft

A test is failing and I believe it's because of an issue in franz-go twmb/franz-go#1139. I'll keep this in draft until that's resolved

Problem

it's possible that some fetches throw off our estimations for the bytes per record. The fetchWant will attempt to fetch the number of records it was given, but if UpdateBytesPerRecord was called by the fetcher worker in the snippet below with a very high average for each record, then it's possible that the fetchWant goes over its targetMaxBytes

w = w.UpdateBytesPerRecord(bufferedResult.fetchedBytes, len(bufferedResult.Records)) // This takes into account the previous fetch too. This should give us a better average than using just the records from the last attempt.

What this PR does

This PR renames the previous targetMaxBytes to maxBytesLimit and enforces it in invocations to MaxBytes(). That way we also cap the memory usage of the fetcher worker.

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

### Problem
it's possible that some fetches throw off our estimations for the bytes per record. The `fetchWant` will attempt to fetch the number of records it was given, but if `UpdateBytesPerRecord` was called by the fetcher worker in the snippet below with a very high average for each record, then it's possible that the `fetchWant` goes over its `targetMaxBytes`

https://github.com/grafana/mimir/blob/1fdeb12b59ffe9682c3eb6980d9c79f777c2b651/pkg/storage/ingest/fetcher.go#L762

### What this PR does

This PR renames the previous `targetMaxBytes` to `maxBytesLimit` and enforces it in invocations to `MaxBytes()`. That way we also cap the memory usage of the fetcher worker.
@dimitarvdimitrov
Copy link
Contributor Author

🤖 Automated comment

The CHANGELOG has just been cut to prepare for the next release. Please rebase main and eventually move the CHANGELOG entry added / updated in this PR to the top of the CHANGELOG.md document. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant