From 667ed9695766d285ceac2638142cbc27d679d3cc Mon Sep 17 00:00:00 2001 From: vivian Date: Tue, 13 Oct 2020 23:11:52 +0800 Subject: [PATCH] wal: remove redundant war tmp dirs if create wal failed (#12388) If we create 000000000-0000000.war failed in war tmp dir(XXX.tmp) and we should remove the tmp dirs. If create war successfully in tmp dir and it will be renamed to common dir and remove tmp dir(XXX.tmp) will also be ok. Co-authored-by: yangweiwei --- wal/wal.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wal/wal.go b/wal/wal.go index ac04ef3c2..9f847f378 100644 --- a/wal/wal.go +++ b/wal/wal.go @@ -114,6 +114,8 @@ func Create(lg *zap.Logger, dirpath string, metadata []byte) (*WAL, error) { return nil, err } } + defer os.RemoveAll(tmpdirpath) + if err := fileutil.CreateDirAll(tmpdirpath); err != nil { lg.Warn( "failed to create a temporary WAL directory",