diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d048b6..8836485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ v1.8.11 [unreleased] ------------------- - [#21659](https://github.com/influxdata/influxdb/pull/21659): fix: do not close connection twice in DigestWithOptions +- [#21666](https://github.com/influxdata/influxdb/pull/21666): fix: do not panic on cleaning up failed iterators v1.8.10 [2021-10-11] ------------------- diff --git a/query/iterator.go b/query/iterator.go index 79a84a3..6706a6b 100644 --- a/query/iterator.go +++ b/query/iterator.go @@ -43,11 +43,22 @@ func (a Iterators) Stats() IteratorStats { } // Close closes all iterators. -func (a Iterators) Close() error { +// We are seeing an occasional panic in this function +// which looks like a nil reference from one +// itr.Close() call, thus we check for nil elements +// in the slice a. This is often called as error +// clean-up, so the state of the iterators may be +// unhappy. +func (a Iterators) Close() (err error) { + err = nil for _, itr := range a { - itr.Close() + if itr != nil { + if e := itr.Close(); e != nil && err == nil { + err = e + } + } } - return nil + return err } // filterNonNil returns a slice of iterators that removes all nil iterators.