From 91e7aaee09a4c086164ca1058221f7249d6c584c Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Wed, 9 Aug 2017 14:46:44 -0700 Subject: [PATCH 1/3] fixes a memory leak when NewReaderIterator creates a nilFloatIterator --- influxql/iterator.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/influxql/iterator.go b/influxql/iterator.go index f89fca6c6cd..7c05c93bd40 100644 --- a/influxql/iterator.go +++ b/influxql/iterator.go @@ -626,7 +626,7 @@ func NewReaderIterator(r io.Reader, typ DataType, stats IteratorStats) Iterator case Boolean: return newBooleanReaderIterator(r, stats) default: - return &nilFloatIterator{} + return &nilFloatReaderIterator{r: r} } } @@ -1233,6 +1233,19 @@ func (*nilFloatIterator) Stats() IteratorStats { return IteratorStats{} } func (*nilFloatIterator) Close() error { return nil } func (*nilFloatIterator) Next() (*FloatPoint, error) { return nil, nil } +type nilFloatReaderIterator struct { + r io.Reader +} + +func (*nilFloatReaderIterator) Stats() IteratorStats { return IteratorStats{} } +func (itr *nilFloatReaderIterator) Close() error { + if r, ok := itr.r.(io.ReadCloser); ok { + return r.Close() + } + return nil +} +func (*nilFloatReaderIterator) Next() (*FloatPoint, error) { return nil, nil } + // integerFloatTransformIterator executes a function to modify an existing point for every // output of the input iterator. type integerFloatTransformIterator struct { From bf30282e538105e12041d7116f07dcc3126bc672 Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Wed, 9 Aug 2017 14:52:27 -0700 Subject: [PATCH 2/3] update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87f531f00eb..bef808c3928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,13 @@ - [#8607](https://github.com/influxdata/influxdb/issues/8607): Fix time zone shifts when the shift happens on a time zone boundary. - [#8639](https://github.com/influxdata/influxdb/issues/8639): Parse time literals using the time zone in the select statement. -## v1.3.2 [unreleased] +## v1.3.3 [unreleased] + +### Bugfixes + +- [#8681](https://github.com/influxdata/influxdb/pull/8681): Resolves a memory leak when NewReaderIterator creates a nilFloatIterator, the reader is not closed + +## v1.3.2 [2017-08-04] ### Bugfixes From f2d0142d834164bb2ee1cd78c4a90a7d129cd4d3 Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Wed, 9 Aug 2017 14:56:24 -0700 Subject: [PATCH 3/3] release io.Reader --- influxql/iterator.go | 1 + 1 file changed, 1 insertion(+) diff --git a/influxql/iterator.go b/influxql/iterator.go index 7c05c93bd40..007e4a8efb3 100644 --- a/influxql/iterator.go +++ b/influxql/iterator.go @@ -1240,6 +1240,7 @@ type nilFloatReaderIterator struct { func (*nilFloatReaderIterator) Stats() IteratorStats { return IteratorStats{} } func (itr *nilFloatReaderIterator) Close() error { if r, ok := itr.r.(io.ReadCloser); ok { + itr.r = nil return r.Close() } return nil