mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
4696b46dd5
Two issues are fixed here, that lead to the same problem: 1. If `newSampleRing` is called with an unknown ValueType including ValueNone, we have initialized the interface buffer (`iBuf`). However, we would still use a specialized buffer for the first sample, opportunistically assuming that we might still not encounter mixed samples and we should go down the more efficient road. 2. If the `sampleRing` is `reset`, we leave all buffers alone, including `iBuf`, which is generally fine, but not for `iBuf`, see below. In both cases, `iBuf` already contains values, but we will fill one of the specialized buffers first. Once we then actually encounter mixed samples, the content of the specialized buffer is copied into `iBuf` using `append`. That's by itself the right idea because `iBuf` might be `nil`, and even if not, it might or might not have the right capacity. However, this approach assumes that `iBuf` is empty, or more precisely has a length of zero. This commit makes sure that `iBuf` does not get needlessly initialized in `newSampleRing` and that it is emptied upon `reset`. A test case is added to demonstrate both issues above. Signed-off-by: beorn7 <beorn@grafana.com> |
||
---|---|---|
.. | ||
remote | ||
buffer.go | ||
buffer_test.go | ||
fanout.go | ||
fanout_test.go | ||
generic.go | ||
interface.go | ||
lazy.go | ||
memoized_iterator.go | ||
memoized_iterator_test.go | ||
merge.go | ||
merge_test.go | ||
noop.go | ||
secondary.go | ||
series.go | ||
series_test.go |