Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
remove unused changes variable (#391)
Browse files Browse the repository at this point in the history
This was added in
55a9b54

and later not used after some refactoring in following PRs.

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
  • Loading branch information
krasi-georgiev authored Sep 21, 2018
1 parent 2db59a7 commit d38516b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -366,20 +366,20 @@ 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.
// They have the highest priority.
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
Expand All @@ -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()
}
Expand All @@ -418,31 +417,30 @@ 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
}

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) {
Expand Down
4 changes: 2 additions & 2 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit d38516b

Please sign in to comment.