kafka replay speed: don't trim fetchWants #9919
Merged
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 this PR does
I realized that trimming
fetchWant
s can end up discarding offsets in extreme circumstances.How it works
If the fetchWant is so big that its size would exceed 2GiB, then we trim it. We trim it by reducing the end offset. The idea is that the next fetchWant will pick up from where this one left off.
How it can break
We trim the
fetchWant
inUpdateBytesPerRecord
too.UpdateBytesPerRecord
can be invoked inconcurrentFEtchers.run
after thefetchWant
is dispatched. In that case the nextfetchWant
would have already been calculated. And we would end up with a gap.Did it break?
It's hard to tell, but it's very unlikely. To reach 2GiB we would have needed to have the estimation for bytes per record be 2 MiB (with 1000 records per fetch). While these large records are possible, they should be rare and our rolling average estimation for records size shouldn't reach it.
Why we can do without
trimIfTooBig()
?MaxBytes()
already caps the value to MaxInt32, so we're compliant with the Kafka Protocol.mimir/pkg/storage/ingest/fetcher.go
Lines 97 to 102 in 175bef4
Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.