Browse Source

chunks: close all opened MmapFiles on NewDirReader error path (#575)

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
pull/5805/head
Pavel Borzenkov 6 years ago committed by Krasi Georgiev
parent
commit
4f204dcbc1
  1. 1
      CHANGELOG.md
  2. 6
      chunks/chunks.go

1
CHANGELOG.md

@ -3,6 +3,7 @@
- [REMOVED] `FromData` is considered unused so was removed. - [REMOVED] `FromData` is considered unused so was removed.
- [FEATURE] Added option WALSegmentSize -1 to disable the WAL. - [FEATURE] Added option WALSegmentSize -1 to disable the WAL.
- [BUGFIX] Fsync the meta file to persist it on disk to avoid data loss in case of a host crash. - [BUGFIX] Fsync the meta file to persist it on disk to avoid data loss in case of a host crash.
- [BUGFIX] Fix fd and vm_area leak on error path in chunks.NewDirReader
## 0.6.1 ## 0.6.1
- [BUGFIX] Update `last` after appending a non-overlapping chunk in `chunks.MergeOverlappingChunks`. [#539](https://github.com/prometheus/tsdb/pull/539) - [BUGFIX] Update `last` after appending a non-overlapping chunk in `chunks.MergeOverlappingChunks`. [#539](https://github.com/prometheus/tsdb/pull/539)

6
chunks/chunks.go

@ -410,11 +410,14 @@ func NewDirReader(dir string, pool chunkenc.Pool) (*Reader, error) {
var ( var (
bs []ByteSlice bs []ByteSlice
cs []io.Closer cs []io.Closer
merr tsdb_errors.MultiError
) )
for _, fn := range files { for _, fn := range files {
f, err := fileutil.OpenMmapFile(fn) f, err := fileutil.OpenMmapFile(fn)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "mmap files") merr.Add(errors.Wrap(err, "mmap files"))
merr.Add(closeAll(cs))
return nil, merr
} }
cs = append(cs, f) cs = append(cs, f)
bs = append(bs, realByteSlice(f.Bytes())) bs = append(bs, realByteSlice(f.Bytes()))
@ -422,7 +425,6 @@ func NewDirReader(dir string, pool chunkenc.Pool) (*Reader, error) {
reader, err := newReader(bs, cs, pool) reader, err := newReader(bs, cs, pool)
if err != nil { if err != nil {
var merr tsdb_errors.MultiError
merr.Add(err) merr.Add(err)
merr.Add(closeAll(cs)) merr.Add(closeAll(cs))
return nil, merr return nil, merr

Loading…
Cancel
Save