diff --git a/storage/merge.go b/storage/merge.go index c57a24c76..fca052ca1 100644 --- a/storage/merge.go +++ b/storage/merge.go @@ -467,6 +467,7 @@ func (c *chainSampleIterator) Seek(t int64) bool { } if len(c.h) > 0 { c.curr = heap.Pop(&c.h).(chunkenc.Iterator) + c.lastt, _ = c.curr.At() return true } c.curr = nil diff --git a/storage/merge_test.go b/storage/merge_test.go index 415b7fb60..2ed68879a 100644 --- a/storage/merge_test.go +++ b/storage/merge_test.go @@ -647,6 +647,14 @@ func TestChainSampleIteratorSeek(t *testing.T) { seek: 2, expected: []tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{4, 4}, sample{5, 5}}, }, + { + input: []chunkenc.Iterator{ + NewListSeriesIterator(samples{sample{0, 0}, sample{2, 2}, sample{3, 3}}), + NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}, sample{2, 2}}), + }, + seek: 0, + expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}}, + }, } { merged := newChainSampleIterator(tc.input) actual := []tsdbutil.Sample{}