mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Fix similar issue for Next() as well.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
This commit is contained in:
parent
6976e003cb
commit
4bf8ec202c
|
@ -576,7 +576,13 @@ func (c *chainSampleIterator) Next() chunkenc.ValueType {
|
|||
// So, we don't call Next() on it here.
|
||||
c.curr = c.iterators[0]
|
||||
for _, iter := range c.iterators[1:] {
|
||||
if iter.Next() != chunkenc.ValNone {
|
||||
if iter.Next() == chunkenc.ValNone {
|
||||
if iter.Err() != nil {
|
||||
// If any iterator is reporting an error, abort.
|
||||
// If c.iterators[0] is reporting an error, we'll handle that below.
|
||||
return chunkenc.ValNone
|
||||
}
|
||||
} else {
|
||||
heap.Push(&c.h, iter)
|
||||
}
|
||||
}
|
||||
|
@ -608,6 +614,9 @@ func (c *chainSampleIterator) Next() chunkenc.ValueType {
|
|||
}
|
||||
// Current iterator does not hold the smallest timestamp.
|
||||
heap.Push(&c.h, c.curr)
|
||||
} else if c.curr.Err() != nil {
|
||||
// Abort if we've hit an error.
|
||||
return chunkenc.ValNone
|
||||
} else if len(c.h) == 0 {
|
||||
// No iterator left to iterate.
|
||||
c.curr = nil
|
||||
|
|
|
@ -1154,6 +1154,25 @@ func TestChainSampleIteratorSeekFailingIterator(t *testing.T) {
|
|||
require.EqualError(t, merged.Err(), "something went wrong")
|
||||
}
|
||||
|
||||
func TestChainSampleIteratorNextImmediatelyFailingIterator(t *testing.T) {
|
||||
merged := ChainSampleIteratorFromIterators(nil, []chunkenc.Iterator{
|
||||
NewListSeriesIterator(samples{fSample{0, 0.1}, fSample{1, 1.1}, fSample{2, 2.1}}),
|
||||
errIterator{errors.New("something went wrong")},
|
||||
})
|
||||
|
||||
require.Equal(t, chunkenc.ValNone, merged.Next())
|
||||
require.EqualError(t, merged.Err(), "something went wrong")
|
||||
|
||||
// Next() does some special handling for the first iterator, so make sure it handles the first iterator returning an error too.
|
||||
merged = ChainSampleIteratorFromIterators(nil, []chunkenc.Iterator{
|
||||
errIterator{errors.New("something went wrong")},
|
||||
NewListSeriesIterator(samples{fSample{0, 0.1}, fSample{1, 1.1}, fSample{2, 2.1}}),
|
||||
})
|
||||
|
||||
require.Equal(t, chunkenc.ValNone, merged.Next())
|
||||
require.EqualError(t, merged.Err(), "something went wrong")
|
||||
}
|
||||
|
||||
func TestChainSampleIteratorSeekHistogramCounterResetHint(t *testing.T) {
|
||||
for sampleType, sampleFunc := range map[string]func(int64, histogram.CounterResetHint) chunks.Sample{
|
||||
"histogram": func(ts int64, hint histogram.CounterResetHint) chunks.Sample { return histogramSample(ts, hint) },
|
||||
|
|
Loading…
Reference in a new issue