Add WrappedHistogram with size limit before unmarshal#7570
Merged
danielblando merged 1 commit intoMay 29, 2026
Merged
Conversation
489220d to
2c5d5a1
Compare
1ecb7ca to
e476d78
Compare
SungJin1212
reviewed
May 29, 2026
Comment on lines
-1440
to
-1454
| // Ensure the appender is always released so that we don't leak TSDB head | ||
| // series references, mmap'd chunks and pending state on early returns. | ||
| // `committed` is flipped to true immediately before app.Commit() because | ||
| // Prometheus closes the appender even on Commit failure (it self-rolls | ||
| // back internally on WAL error), so the deferred Rollback must not run | ||
| // afterwards. | ||
| committed := false | ||
| defer func() { | ||
| if committed { | ||
| return | ||
| } | ||
| if rollbackErr := app.Rollback(); rollbackErr != nil { | ||
| level.Warn(logutil.WithContext(ctx, i.logger)).Log("msg", "failed to rollback appender on early return", "user", userID, "err", rollbackErr) | ||
| } | ||
| }() |
Member
There was a problem hiding this comment.
This code block seems to have been deleted by mistake.
Contributor
There was a problem hiding this comment.
Yeah seems a mistake from rebase
Contributor
Author
There was a problem hiding this comment.
Thanks for catching this. I copied some code from private to here which removed this. Corrected it now.
Signed-off-by: Paurush Garg <paurushg@amazon.com>
e476d78 to
fee7e0c
Compare
danielblando
approved these changes
May 29, 2026
4 tasks
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 this PR does:
Adds a WrappedHistogram wrapper type (same pattern as PreallocTimeseries) that checks raw protobuf byte size before calling the generated Histogram.Unmarshal. This limits memory allocation during deserialization of packed repeated scalar fields (NegativeDeltas, PositiveDeltas) on the ingestion path.
Which issue(s) this PR fixes:
Fixes #
Checklist
docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags