From b521612042ec87103088b45b7b5dfee3bb8dc732 Mon Sep 17 00:00:00 2001 From: johncming Date: Fri, 14 Aug 2020 17:45:08 +0800 Subject: [PATCH] tsdb: simplify code. (#7792) Signed-off-by: johncming --- tsdb/db.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tsdb/db.go b/tsdb/db.go index e6772b9f3..b045fa155 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -572,8 +572,11 @@ func open(dir string, l log.Logger, r prometheus.Registerer, opts *Options, rngs if err := repairBadIndexVersion(l, dir); err != nil { return nil, errors.Wrap(err, "repair bad index version") } + + walDir := filepath.Join(dir, "wal") + // Migrate old WAL if one exists. - if err := MigrateWAL(l, filepath.Join(dir, "wal")); err != nil { + if err := MigrateWAL(l, walDir); err != nil { return nil, errors.Wrap(err, "migrate WAL") } // Remove garbage, tmp blocks. @@ -618,7 +621,6 @@ func open(dir string, l log.Logger, r prometheus.Registerer, opts *Options, rngs var wlog *wal.WAL segmentSize := wal.DefaultSegmentSize - walDir := filepath.Join(dir, "wal") // Wal is enabled. if opts.WALSegmentSize >= 0 { // Wal is set to a custom size.