Skip to content

Commit

Permalink
Merge pull request #8681 from influxdata/sgc-1341
Browse files Browse the repository at this point in the history
fixes a memory leak when NewReaderIterator creates a nilFloatIterator
  • Loading branch information
stuartcarnie committed Aug 9, 2017
2 parents 392fa03 + f2d0142 commit 50f7a7f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 15 additions & 1 deletion influxql/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}

Expand Down Expand Up @@ -1233,6 +1233,20 @@ 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 {
itr.r = nil
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 {
Expand Down

0 comments on commit 50f7a7f

Please sign in to comment.