tsdb: simplify code. (#7792)

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2020-08-14 17:45:08 +08:00 committed by GitHub
parent 362080ba28
commit b521612042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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.