chunks: close all opened MmapFiles on NewDirReader error path (#575)
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
This commit is contained in:
parent
e46ec89de6
commit
4f204dcbc1
|
@ -3,6 +3,7 @@
|
|||
- [REMOVED] `FromData` is considered unused so was removed.
|
||||
- [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] Fix fd and vm_area leak on error path in chunks.NewDirReader
|
||||
|
||||
## 0.6.1
|
||||
- [BUGFIX] Update `last` after appending a non-overlapping chunk in `chunks.MergeOverlappingChunks`. [#539](https://github.com/prometheus/tsdb/pull/539)
|
||||
|
|
|
@ -408,13 +408,16 @@ func NewDirReader(dir string, pool chunkenc.Pool) (*Reader, error) {
|
|||
}
|
||||
|
||||
var (
|
||||
bs []ByteSlice
|
||||
cs []io.Closer
|
||||
bs []ByteSlice
|
||||
cs []io.Closer
|
||||
merr tsdb_errors.MultiError
|
||||
)
|
||||
for _, fn := range files {
|
||||
f, err := fileutil.OpenMmapFile(fn)
|
||||
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)
|
||||
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)
|
||||
if err != nil {
|
||||
var merr tsdb_errors.MultiError
|
||||
merr.Add(err)
|
||||
merr.Add(closeAll(cs))
|
||||
return nil, merr
|
||||
|
|
Loading…
Reference in New Issue