From ca530d7f85ca38c1dfecb16e36dd72718ea552e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Krajcsovits?= Date: Thu, 22 Jan 2026 18:08:41 +0100 Subject: [PATCH] fix issue with seeking to last sample again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: György Krajcsovits --- tsdb/chunkenc/chunk_test.go | 4 ++++ tsdb/chunkenc/xoroptst.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tsdb/chunkenc/chunk_test.go b/tsdb/chunkenc/chunk_test.go index 92fa3cab38..1717300288 100644 --- a/tsdb/chunkenc/chunk_test.go +++ b/tsdb/chunkenc/chunk_test.go @@ -110,10 +110,14 @@ func testChunk(t *testing.T, c Chunk, supportsST bool) { ts, v = it3.At() res3 = append(res3, triple{st: it3.AtST(), t: ts, v: v}) + lastTs := ts for it3.Next() == ValFloat { ts, v := it3.At() + lastTs = ts res3 = append(res3, triple{st: it3.AtST(), t: ts, v: v}) } + // Seeking to last timestamp should work and it is a no-op. + require.Equal(t, ValFloat, it3.Seek(lastTs)) require.NoError(t, it3.Err()) require.Equal(t, exp[mid:], res3) require.Equal(t, ValNone, it3.Seek(exp[len(exp)-1].t+1)) diff --git a/tsdb/chunkenc/xoroptst.go b/tsdb/chunkenc/xoroptst.go index 5271398bd1..e61882fd84 100644 --- a/tsdb/chunkenc/xoroptst.go +++ b/tsdb/chunkenc/xoroptst.go @@ -207,7 +207,7 @@ type xorOptSTtIterator struct { } func (it *xorOptSTtIterator) Seek(t int64) ValueType { - if it.state == eofState { + if it.err != nil { return ValNone }