From 030d3232ff2ab8bf8a25d670a9f4566985bb35c4 Mon Sep 17 00:00:00 2001 From: Dylan Guedes Date: Wed, 22 Feb 2023 17:39:37 -0300 Subject: [PATCH] Loki: Fix memchunk headblock filter (#8591) **What this PR does / why we need it**: Fix our memchunk headblock filter to not skip entries that have timestamp=maxT. --- pkg/chunkenc/memchunk.go | 5 ++++- pkg/chunkenc/memchunk_test.go | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/chunkenc/memchunk.go b/pkg/chunkenc/memchunk.go index 61fc170a25..90f82a90f4 100644 --- a/pkg/chunkenc/memchunk.go +++ b/pkg/chunkenc/memchunk.go @@ -1005,7 +1005,10 @@ func (hb *headBlock) Iterator(ctx context.Context, direction logproto.Direction, baseHash := pipeline.BaseLabels().Hash() process := func(e entry) { // apply time filtering - if e.t < mint || e.t >= maxt { + if e.t < mint || e.t > maxt { + return + } + if e.t == maxt && mint != maxt { return } stats.AddHeadChunkBytes(int64(len(e.s))) diff --git a/pkg/chunkenc/memchunk_test.go b/pkg/chunkenc/memchunk_test.go index 1485b462d7..b849a4bcf3 100644 --- a/pkg/chunkenc/memchunk_test.go +++ b/pkg/chunkenc/memchunk_test.go @@ -911,8 +911,6 @@ func TestMemChunk_IteratorBounds(t *testing.T) { t.Run( fmt.Sprintf("mint:%d,maxt:%d,direction:%s", tt.mint.UnixNano(), tt.maxt.UnixNano(), tt.direction), func(t *testing.T) { - t.Parallel() - tt := tt c := createChunk()