always remove tmp

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
Krasi Georgiev 2019-02-06 16:09:42 +02:00
parent 45acaadd81
commit 08e7bc8ee8
1 changed files with 6 additions and 8 deletions

View File

@ -493,12 +493,13 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
for _, w := range writers {
merr.Add(w.Close())
}
if merr.Err() != nil {
c.metrics.failed.Inc()
// TODO(gouthamve): Handle error how?
// RemoveAll returns no error when tmp doesn't exist so it is safe to always run it.
if err := os.RemoveAll(tmp); err != nil {
level.Error(c.logger).Log("msg", "removed tmp folder after failed compaction", "err", err.Error())
}
if merr.Err() != nil {
c.metrics.failed.Inc()
}
c.metrics.ran.Inc()
c.metrics.duration.Observe(time.Since(t).Seconds())
@ -559,11 +560,8 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
return merr.Err()
}
// Populated block is empty, so cleanup and exit.
// Populated block is empty, so exit early.
if meta.Stats.NumSamples == 0 {
if err := os.RemoveAll(tmp); err != nil {
return errors.Wrap(err, "remove tmp folder after empty block failed")
}
return nil
}