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

Commit

Permalink
cleanup tmp meta file if file renaming failed
Browse files Browse the repository at this point in the history
Signed-off-by: zhulongcheng <[email protected]>
  • Loading branch information
zhulongcheng committed Apr 4, 2019
1 parent 520b1d8 commit 6ad3d42
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/prometheus/tsdb/chunkenc"
"github.com/prometheus/tsdb/chunks"
tsdb_errors "github.com/prometheus/tsdb/errors"
"github.com/prometheus/tsdb/fileutil"
"github.com/prometheus/tsdb/index"
"github.com/prometheus/tsdb/labels"
)
Expand Down Expand Up @@ -259,7 +260,14 @@ func writeMetaFile(dir string, meta *BlockMeta) error {
if err := f.Close(); err != nil {
return err
}
return renameFile(tmp, path)

if err := fileutil.Rename(tmp, path); err != nil {
merr.Add(err)
merr.Add(os.RemoveAll(tmp))
return merr.Err()
}

return nil
}

// Block represents a directory of time series data covering a continuous time range.
Expand Down

0 comments on commit 6ad3d42

Please sign in to comment.