From 201491fd1b6b02fab60f7630dff23218bc3d1067 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 14 Jan 2020 10:35:24 +0100 Subject: [PATCH] Remove old checkpoint dir if it still exists (#6621) Signed-off-by: Julien Pivotto --- tsdb/wal/checkpoint.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tsdb/wal/checkpoint.go b/tsdb/wal/checkpoint.go index 8d3cc8ab6..6b0ecd54f 100644 --- a/tsdb/wal/checkpoint.go +++ b/tsdb/wal/checkpoint.go @@ -133,6 +133,10 @@ func Checkpoint(w *WAL, from, to int, keep func(id uint64) bool, mint int64) (*C cpdir := filepath.Join(w.Dir(), fmt.Sprintf(checkpointPrefix+"%06d", to)) cpdirtmp := cpdir + ".tmp" + if err := os.RemoveAll(cpdirtmp); err != nil { + return nil, errors.Wrap(err, "remove previous temporary checkpoint dir") + } + if err := os.MkdirAll(cpdirtmp, 0777); err != nil { return nil, errors.Wrap(err, "create checkpoint dir") }