Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
Dont write empty blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Ganesh Vernekar <[email protected]>
  • Loading branch information
codesome committed Sep 8, 2018
1 parent eeb3a74 commit d2d6cd1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,13 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
df = nil

// Block successfully written, make visible and remove old ones.
if err := renameFile(tmp, dir); err != nil {
return errors.Wrap(err, "rename block dir")
if meta.Stats.NumSamples > 0 {
// Rename to a new block only if we have samples.
if err := renameFile(tmp, dir); err != nil {
return errors.Wrap(err, "rename block dir")
}
} else if err := os.RemoveAll(tmp); err != nil {
return errors.Wrap(err, "remove tmp folder after empty block failed")
}

return nil
Expand Down

0 comments on commit d2d6cd1

Please sign in to comment.