mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
Merge pull request #14605 from krajorama/fix-staleness-pool-corrupt
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (0) (push) Waiting to run
CI / Build Prometheus for common architectures (1) (push) Waiting to run
CI / Build Prometheus for common architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (0) (push) Waiting to run
CI / Build Prometheus for all architectures (1) (push) Waiting to run
CI / Build Prometheus for all architectures (10) (push) Waiting to run
CI / Build Prometheus for all architectures (11) (push) Waiting to run
CI / Build Prometheus for all architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (3) (push) Waiting to run
CI / Build Prometheus for all architectures (4) (push) Waiting to run
CI / Build Prometheus for all architectures (5) (push) Waiting to run
CI / Build Prometheus for all architectures (6) (push) Waiting to run
CI / Build Prometheus for all architectures (7) (push) Waiting to run
CI / Build Prometheus for all architectures (8) (push) Waiting to run
CI / Build Prometheus for all architectures (9) (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (0) (push) Waiting to run
CI / Build Prometheus for common architectures (1) (push) Waiting to run
CI / Build Prometheus for common architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (0) (push) Waiting to run
CI / Build Prometheus for all architectures (1) (push) Waiting to run
CI / Build Prometheus for all architectures (10) (push) Waiting to run
CI / Build Prometheus for all architectures (11) (push) Waiting to run
CI / Build Prometheus for all architectures (2) (push) Waiting to run
CI / Build Prometheus for all architectures (3) (push) Waiting to run
CI / Build Prometheus for all architectures (4) (push) Waiting to run
CI / Build Prometheus for all architectures (5) (push) Waiting to run
CI / Build Prometheus for all architectures (6) (push) Waiting to run
CI / Build Prometheus for all architectures (7) (push) Waiting to run
CI / Build Prometheus for all architectures (8) (push) Waiting to run
CI / Build Prometheus for all architectures (9) (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Fix histogram pool poisoning bug chunkenc.Iterator
This commit is contained in:
commit
27579c9148
|
@ -2356,6 +2356,11 @@ loop:
|
||||||
} else {
|
} else {
|
||||||
histograms = append(histograms, HPoint{H: &histogram.FloatHistogram{}})
|
histograms = append(histograms, HPoint{H: &histogram.FloatHistogram{}})
|
||||||
}
|
}
|
||||||
|
if histograms[n].H == nil {
|
||||||
|
// Make sure to pass non zero H to AtFloatHistogram so that it does a deep-copy.
|
||||||
|
// Not an issue in the loop above since that uses an intermediate buffer.
|
||||||
|
histograms[n].H = &histogram.FloatHistogram{}
|
||||||
|
}
|
||||||
histograms[n].T, histograms[n].H = it.AtFloatHistogram(histograms[n].H)
|
histograms[n].T, histograms[n].H = it.AtFloatHistogram(histograms[n].H)
|
||||||
if value.IsStaleNaN(histograms[n].H.Sum) {
|
if value.IsStaleNaN(histograms[n].H.Sum) {
|
||||||
histograms = histograms[:n]
|
histograms = histograms[:n]
|
||||||
|
|
|
@ -3797,3 +3797,62 @@ func makeInt64Pointer(val int64) *int64 {
|
||||||
*valp = val
|
*valp = val
|
||||||
return valp
|
return valp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHistogramCopyFromIteratorRegression(t *testing.T) {
|
||||||
|
// Loading the following histograms creates two chunks because there's a
|
||||||
|
// counter reset. Not only the counter is lower in the last histogram
|
||||||
|
// but also there's missing buckets.
|
||||||
|
// This in turns means that chunk iterators will have different spans.
|
||||||
|
load := `load 1m
|
||||||
|
histogram {{sum:4 count:4 buckets:[2 2]}} {{sum:6 count:6 buckets:[3 3]}} {{sum:1 count:1 buckets:[1]}}
|
||||||
|
`
|
||||||
|
storage := promqltest.LoadedStorage(t, load)
|
||||||
|
t.Cleanup(func() { storage.Close() })
|
||||||
|
engine := promqltest.NewTestEngine(false, 0, promqltest.DefaultMaxSamplesPerQuery)
|
||||||
|
|
||||||
|
verify := func(t *testing.T, qry promql.Query, expected []histogram.FloatHistogram) {
|
||||||
|
res := qry.Exec(context.Background())
|
||||||
|
require.NoError(t, res.Err)
|
||||||
|
|
||||||
|
m, ok := res.Value.(promql.Matrix)
|
||||||
|
require.True(t, ok)
|
||||||
|
|
||||||
|
require.Len(t, m, 1)
|
||||||
|
series := m[0]
|
||||||
|
|
||||||
|
require.Empty(t, series.Floats)
|
||||||
|
require.Len(t, series.Histograms, len(expected))
|
||||||
|
for i, e := range expected {
|
||||||
|
series.Histograms[i].H.CounterResetHint = histogram.UnknownCounterReset // Don't care.
|
||||||
|
require.Equal(t, &e, series.Histograms[i].H)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qry, err := engine.NewRangeQuery(context.Background(), storage, nil, "increase(histogram[60s])", time.Unix(0, 0), time.Unix(0, 0).Add(1*time.Minute), time.Minute)
|
||||||
|
require.NoError(t, err)
|
||||||
|
verify(t, qry, []histogram.FloatHistogram{
|
||||||
|
{
|
||||||
|
Count: 2,
|
||||||
|
Sum: 2, // Increase from 4 to 6 is 2.
|
||||||
|
PositiveSpans: []histogram.Span{{Offset: 0, Length: 2}}, // Two buckets changed between the first and second histogram.
|
||||||
|
PositiveBuckets: []float64{1, 1}, // Increase from 2 to 3 is 1 in both buckets.
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
qry, err = engine.NewInstantQuery(context.Background(), storage, nil, "histogram[60s]", time.Unix(0, 0).Add(2*time.Minute))
|
||||||
|
require.NoError(t, err)
|
||||||
|
verify(t, qry, []histogram.FloatHistogram{
|
||||||
|
{
|
||||||
|
Count: 6,
|
||||||
|
Sum: 6,
|
||||||
|
PositiveSpans: []histogram.Span{{Offset: 0, Length: 2}},
|
||||||
|
PositiveBuckets: []float64{3, 3},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Count: 1,
|
||||||
|
Sum: 1,
|
||||||
|
PositiveSpans: []histogram.Span{{Offset: 0, Length: 1}},
|
||||||
|
PositiveBuckets: []float64{1},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue