Browse Source

Fix directory file descriptor leak.

pull/5805/head
Fabian Reinartz 8 years ago
parent
commit
03f95ee096
  1. 4
      compact.go
  2. 2
      db.go

4
compact.go

@ -300,6 +300,8 @@ func (c *compactor) write(uid ulid.ULID, blocks ...Block) (err error) {
if err != nil { if err != nil {
return errors.Wrap(err, "sync block dir") return errors.Wrap(err, "sync block dir")
} }
defer df.Close()
if err := fileutil.Fsync(df); err != nil { if err := fileutil.Fsync(df); err != nil {
return errors.Wrap(err, "sync block dir") return errors.Wrap(err, "sync block dir")
} }
@ -583,6 +585,8 @@ func renameFile(from, to string) error {
if err != nil { if err != nil {
return err return err
} }
defer pdir.Close()
if err = fileutil.Fsync(pdir); err != nil { if err = fileutil.Fsync(pdir); err != nil {
return err return err
} }

2
db.go

@ -386,6 +386,8 @@ func retentionCutoff(dir string, mint int64) (bool, error) {
if err != nil { if err != nil {
return false, errors.Wrapf(err, "open directory") return false, errors.Wrapf(err, "open directory")
} }
defer df.Close()
dirs, err := blockDirs(dir) dirs, err := blockDirs(dir)
if err != nil { if err != nil {
return false, errors.Wrapf(err, "list block dirs %s", dir) return false, errors.Wrapf(err, "list block dirs %s", dir)

Loading…
Cancel
Save