Skip to content

Commit

Permalink
fixes a panic where prefetch could try to operate on a nil object (#1499
Browse files Browse the repository at this point in the history
)

Signed-off-by: Edward Welch <edward.welch@grafana.com>
  • Loading branch information
slim-bean authored and cyriltovena committed Jan 10, 2020
1 parent ec40515 commit 35dd07c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/storage/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func newBatchChunkIterator(ctx context.Context, chunks []*chunkenc.LazyChunk, ba
select {
case <-ctx.Done():
close(res.next)
// next can be nil if we are waiting to return that the nextBatch was empty and the context is closed
// or if another error occurred reading nextBatch
if next == nil {
return
}
err = next.Close()
if err != nil {
level.Error(util.Logger).Log("msg", "Failed to close the pre-fetched iterator when pre-fetching was canceled", "err", err)
Expand Down

0 comments on commit 35dd07c

Please sign in to comment.