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

Commit

Permalink
add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
krasi-georgiev committed Feb 26, 2018
1 parent 9de8d6f commit 2c0d5d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ func (c *LeveledCompactor) Plan(dir string) ([]string, error) {
for _, dir := range dirs {
meta, err := readMetaFile(dir)
if err != nil {
// No need to return an error as this will be deleted when reloading the db.
level.Debug(c.logger).Log("msg", "couldn't read a block meta file at planning", "err", err)
// We continue with the rest of the blocks.
// This one will be deleted when reloading the db.
continue
}
dms = append(dms, dirMeta{dir, meta})
Expand Down
16 changes: 7 additions & 9 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,16 @@ func retentionCutoffDirs(l log.Logger, dir string, mint int64) ([]string, error)
for _, dir := range dirs {
meta, err := readMetaFile(dir)
if err != nil {
delDirs = append(delDirs, dir)
level.Debug(l).Log("msg", "couldn't read a block meta file at retention", "err", err)
// We continue with the rest of the blocks.
// This one will be deleted when reloading the db.
continue
}
// The first block we encounter marks that we crossed the boundary
// of deletable blocks.
if meta.MaxTime >= mint {
break
}

delDirs = append(delDirs, dir)
}

Expand Down Expand Up @@ -505,14 +506,11 @@ func (db *DB) reload(deleteable ...string) (err error) {
for _, dir := range dirs {
meta, err := readMetaFile(dir)
if err != nil {
if os.IsNotExist(err) {
deleteable = append(deleteable, dir)
level.Error(db.logger).Log("msg", "dir set for deletion due to error in the meta file", "dir", dir, "err", err.Error())
continue
}
return errors.Wrapf(err, "read meta information %s", dir)
deleteable = append(deleteable, dir)
level.Error(db.logger).Log("msg", "block set for deletion due to error in the meta file", "dir", dir, "err", err.Error())
continue
}

// If the block is pending for deletion, don't add it to the new block set.
if stringsContain(deleteable, dir) {
continue
}
Expand Down
3 changes: 3 additions & 0 deletions repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func repairBadIndexVersion(logger log.Logger, dir string) error {
d = path.Join(dir, d)
// Skip dirs with missing meta. These will be deleted when reloading the db.
if _, err := os.Stat(filepath.Join(d, metaFilename)); os.IsNotExist(err) {
level.Debug(logger).Log("msg", "couldn't read a block meta file at index repair", "err", err)
// We continue with the rest of the blocks.
// This one will be deleted when reloading the db.
continue
}

Expand Down

0 comments on commit 2c0d5d8

Please sign in to comment.