Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compact: data corruption during downsapmle, test and fix. #6598

Merged
merged 10 commits into from
Sep 12, 2023
11 changes: 10 additions & 1 deletion pkg/compact/downsample/downsample.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,17 @@ func downsampleRawLoop(data []sample, resolution int64, numChunks int) []chunks.
for ; j < len(data) && data[j].t <= curW; j++ {
}

batch := data[:j]
batch := make([]sample, 0, j)
for _, s := range data[:j] {
if value.IsStaleNaN(s.v) || math.Float64bits(s.v) == value.NormalNaN {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we should filter those NaNs beforehand... So that we can calculate batchSize, windowTime, etc better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/thanos-io/thanos/blob/main/pkg/compact/downsample/downsample.go#L648 the ApplyCounterResetsSeriesIterator ignores NaN values but https://github.com/thanos-io/thanos/blob/main/pkg/compact/downsample/downsample.go#L474 expandChunkIterator only ignores stale NaN.

I am wondering if we should just change this. We have so many places in the code that allows normal NaN and ignores just stale NaN. Not sure what's the correct behavior here. Should we keep the normal NaN? @bwplotka

continue
}
batch = append(batch, s)
}
data = data[j:]
if len(batch) == 0 {
continue
}

ab := newAggrChunkBuilder()

Expand Down