promql: Forget lastFH in HistogramStatsIterator after Seek

After an effective Seek, the lastFH isn't the lastFH anymore, so we
should nil it out.

In practice, this should only matter is sub-queries, because we are
otherwise not interested in a counter reset of the first sample
returned after a Seek.

Sub-queries, on the other hand, always do their own counter reset
detection. (For that, they would prefer to see the whole histogram, so
that's another problem for another commit.)

Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
beorn7 2025-09-04 13:45:24 +02:00
parent 5010bd4bb1
commit 0cef66b12a

View file

@ -61,6 +61,11 @@ func (hsi *HistogramStatsIterator) Next() chunkenc.ValueType {
// Seek mostly relays to the underlying iterator, but changes a ValHistogram
// return into a ValFloatHistogram return.
func (hsi *HistogramStatsIterator) Seek(t int64) chunkenc.ValueType {
// If the Seek is going to move the iterator, we have to forget the
// lastFH.
if t > hsi.AtT() {
hsi.lastFH = nil
}
vt := hsi.Iterator.Seek(t)
if vt == chunkenc.ValHistogram {
return chunkenc.ValFloatHistogram