Fix: EncodeAggrChunk created corrupt block if the last chunk is empty#8684
Open
daijy wants to merge 4 commits intothanos-io:mainfrom
Open
Fix: EncodeAggrChunk created corrupt block if the last chunk is empty#8684daijy wants to merge 4 commits intothanos-io:mainfrom
daijy wants to merge 4 commits intothanos-io:mainfrom
Conversation
Signed-off-by: Daniel Dai <jidai@roku.com>
Signed-off-by: Daniel Dai <jidai@roku.com>
Signed-off-by: Daniel Dai <jidai@roku.com>
GiedriusS
reviewed
Feb 18, 2026
Member
GiedriusS
left a comment
There was a problem hiding this comment.
Does this ever happen in practice or is this theoretical?
We have seen it in production. The cause is still unclear. |
Author
|
It happens when the AggrCounter is missing for the AggrChunk, as shown in the test case. In AggrChunk.Get, it erroneously return "invalid size" instead of ErrAggrNotExist. Should be quite frequent, severity depends on how the caller response. In our parquet downsample converter, it stops converting the rest of tsdb downsample. I fixed it in the write side to write extra bytes for AggrCounter if it's empty, so the reader won't trigger "invalid size". |
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.
This PR fixes a decode failure for aggregate chunks when the last aggregate (AggrCounter) is missing.
In this case, decoding could return invalid size instead of ErrAggrNotExist. Decoder logic expects at least one byte (+1 for encoding marker) even for zero-length entries during pre-check. For the final nil aggregate, that extra byte does not exist in the stream.