diff --git a/storage/remote/codec.go b/storage/remote/codec.go index fa033b589..fb4d777a3 100644 --- a/storage/remote/codec.go +++ b/storage/remote/codec.go @@ -360,6 +360,9 @@ func (c *concreteSeriesIterator) Seek(t int64) bool { if c.cur == -1 { c.cur = 0 } + if c.cur >= len(c.series.samples) { + return false + } // No-op check. if s := c.series.samples[c.cur]; s.Timestamp >= t { return true diff --git a/storage/series.go b/storage/series.go index 024b0fc72..2dba83715 100644 --- a/storage/series.go +++ b/storage/series.go @@ -99,6 +99,9 @@ func (it *listSeriesIterator) Seek(t int64) bool { if it.idx == -1 { it.idx = 0 } + if it.idx >= it.samples.Len() { + return false + } // No-op check. if s := it.samples.Get(it.idx); s.T() >= t { return true diff --git a/tsdb/tsdbutil/buffer_test.go b/tsdb/tsdbutil/buffer_test.go index baae8266b..f19403360 100644 --- a/tsdb/tsdbutil/buffer_test.go +++ b/tsdb/tsdbutil/buffer_test.go @@ -159,6 +159,9 @@ func (it *listSeriesIterator) Seek(t int64) bool { if it.idx == -1 { it.idx = 0 } + if it.idx >= len(it.list) { + return false + } // No-op check. if s := it.list[it.idx]; s.T() >= t { return true