From d38516b1c2e5c6eb118df3fe84c9679153ef08d3 Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Fri, 21 Sep 2018 09:24:01 +0300 Subject: [PATCH] remove unused changes variable (#391) This was added in https://github.com/prometheus/tsdb/commit/55a9b5428aceb644b3b297d7a9fd63d0354ce953 and later not used after some refactoring in following PRs. Signed-off-by: Krasi Georgiev --- db.go | 24 +++++++++++------------- db_test.go | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/db.go b/db.go index 059ef06ea..cb02b4835 100644 --- a/db.go +++ b/db.go @@ -300,7 +300,7 @@ func (db *DB) run() { case <-db.compactc: db.metrics.compactionsTriggered.Inc() - _, err := db.compact() + err := db.compact() if err != nil { level.Error(db.logger).Log("msg", "compaction failed", "err", err) backoff = exponential(backoff, 1*time.Second, 1*time.Minute) @@ -366,12 +366,12 @@ func (a dbAppender) Commit() error { // this is sufficient to reliably delete old data. // Old blocks are only deleted on reload based on the new block's parent information. // See DB.reload documentation for further information. -func (db *DB) compact() (changes bool, err error) { +func (db *DB) compact() (err error) { db.cmtx.Lock() defer db.cmtx.Unlock() if !db.compactionsEnabled { - return false, nil + return nil } // Check whether we have pending head blocks that are ready to be persisted. @@ -379,7 +379,7 @@ func (db *DB) compact() (changes bool, err error) { for { select { case <-db.stopc: - return changes, nil + return nil default: } // The head has a compactable range if 1.5 level 0 ranges are between the oldest @@ -402,14 +402,13 @@ func (db *DB) compact() (changes bool, err error) { maxt: maxt - 1, } if _, err = db.compactor.Write(db.dir, head, mint, maxt, nil); err != nil { - return changes, errors.Wrap(err, "persist head block") + return errors.Wrap(err, "persist head block") } - changes = true runtime.GC() if err := db.reload(); err != nil { - return changes, errors.Wrap(err, "reload blocks") + return errors.Wrap(err, "reload blocks") } runtime.GC() } @@ -418,7 +417,7 @@ func (db *DB) compact() (changes bool, err error) { for { plan, err := db.compactor.Plan(db.dir) if err != nil { - return changes, errors.Wrap(err, "plan compaction") + return errors.Wrap(err, "plan compaction") } if len(plan) == 0 { break @@ -426,23 +425,22 @@ func (db *DB) compact() (changes bool, err error) { select { case <-db.stopc: - return changes, nil + return nil default: } if _, err := db.compactor.Compact(db.dir, plan...); err != nil { - return changes, errors.Wrapf(err, "compact %s", plan) + return errors.Wrapf(err, "compact %s", plan) } - changes = true runtime.GC() if err := db.reload(); err != nil { - return changes, errors.Wrap(err, "reload blocks") + return errors.Wrap(err, "reload blocks") } runtime.GC() } - return changes, nil + return nil } func (db *DB) getBlock(id ulid.ULID) (*Block, bool) { diff --git a/db_test.go b/db_test.go index 6cb18322d..916df5efd 100644 --- a/db_test.go +++ b/db_test.go @@ -1131,7 +1131,7 @@ func TestChunkAtBlockBoundary(t *testing.T) { err := app.Commit() testutil.Ok(t, err) - _, err = db.compact() + err = db.compact() testutil.Ok(t, err) for _, block := range db.blocks { @@ -1183,7 +1183,7 @@ func TestQuerierWithBoundaryChunks(t *testing.T) { err := app.Commit() testutil.Ok(t, err) - _, err = db.compact() + err = db.compact() testutil.Ok(t, err) testutil.Assert(t, len(db.blocks) >= 3, "invalid test, less than three blocks in DB")