From 1226922ff549edd27a2b98fa9b6222b4c05620ab Mon Sep 17 00:00:00 2001 From: Bryan Boreham <bjboreham@gmail.com> Date: Sat, 26 Nov 2022 15:22:59 +0000 Subject: [PATCH] tsdb: improve blockBaseSeriesSet scan Inverting the test for chunks deleted by tombstones makes all three rejections consistent, and also avoids the case where a chunk is excluded but still causes `trimFront` or `trimBack` to be set. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> --- tsdb/querier.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tsdb/querier.go b/tsdb/querier.go index 70b384e020..035bf449c3 100644 --- a/tsdb/querier.go +++ b/tsdb/querier.go @@ -481,10 +481,10 @@ func (b *blockBaseSeriesSet) Next() bool { if chk.MinTime > b.maxt { continue } - - if !(tombstones.Interval{Mint: chk.MinTime, Maxt: chk.MaxTime}.IsSubrange(intervals)) { - chks = append(chks, chk) + if (tombstones.Interval{Mint: chk.MinTime, Maxt: chk.MaxTime}.IsSubrange(intervals)) { + continue } + chks = append(chks, chk) // If still not entirely deleted, check if trim is needed based on requested time range. if !b.disableTrimming {