Commit b8c1e222 authored by Janoš Guljaš's avatar Janoš Guljaš Committed by GitHub

fix localstore log messages (#202)

parent 88906fab
...@@ -125,13 +125,13 @@ func (db *DB) Import(r io.Reader, legacy bool) (count int64, err error) { ...@@ -125,13 +125,13 @@ func (db *DB) Import(r io.Reader, legacy bool) (count int64, err error) {
} }
if len(hdr.Name) != 64 { if len(hdr.Name) != 64 {
db.logger.Warningf("ignoring non-chunk file, name : %s", hdr.Name) db.logger.Warningf("localstore export: ignoring non-chunk file: %s", hdr.Name)
continue continue
} }
keybytes, err := hex.DecodeString(hdr.Name) keybytes, err := hex.DecodeString(hdr.Name)
if err != nil { if err != nil {
db.logger.Warningf("ignoring invalid chunk file. name : %s , Error : %s", hdr.Name, err) db.logger.Warningf("localstore export: ignoring invalid chunk file %s: %v", hdr.Name, err)
continue continue
} }
......
...@@ -18,6 +18,7 @@ package localstore ...@@ -18,6 +18,7 @@ package localstore
import ( import (
"errors" "errors"
"fmt"
"time" "time"
"github.com/ethersphere/bee/pkg/shed" "github.com/ethersphere/bee/pkg/shed"
...@@ -54,7 +55,7 @@ func (db *DB) collectGarbageWorker() { ...@@ -54,7 +55,7 @@ func (db *DB) collectGarbageWorker() {
// another collect garbage run is needed // another collect garbage run is needed
collectedCount, done, err := db.collectGarbage() collectedCount, done, err := db.collectGarbage()
if err != nil { if err != nil {
db.logger.Errorf("localstore collect garbage. Error : %s", err.Error()) db.logger.Errorf("localstore: collect garbage: %v", err)
} }
// check if another gc run is needed // check if another gc run is needed
if !done { if !done {
...@@ -96,8 +97,7 @@ func (db *DB) collectGarbage() (collectedCount uint64, done bool, err error) { ...@@ -96,8 +97,7 @@ func (db *DB) collectGarbage() (collectedCount uint64, done bool, err error) {
// remove them from the gcIndex before iterating through gcIndex // remove them from the gcIndex before iterating through gcIndex
err = db.removeChunksInExcludeIndexFromGC() err = db.removeChunksInExcludeIndexFromGC()
if err != nil { if err != nil {
db.logger.Errorf("localstore exclude pinned chunks. Error : %s", err) return 0, true, fmt.Errorf("remove chunks in exclude index: %v", err)
return 0, true, err
} }
gcSize, err := db.gcSize.Get() gcSize, err := db.gcSize.Get()
......
...@@ -46,7 +46,7 @@ func (db *DB) migrate(schemaName string) error { ...@@ -46,7 +46,7 @@ func (db *DB) migrate(schemaName string) error {
return nil return nil
} }
db.logger.Infof("need to run data migrations on localstore. numMigrations : %s, schemaName : %s ", len(migrations), schemaName) db.logger.Infof("localstore migration: need to run %v data migrations on localstore to schema %s", len(migrations), schemaName)
for i := 0; i < len(migrations); i++ { for i := 0; i < len(migrations); i++ {
err := migrations[i].fn(db) err := migrations[i].fn(db)
if err != nil { if err != nil {
...@@ -60,7 +60,7 @@ func (db *DB) migrate(schemaName string) error { ...@@ -60,7 +60,7 @@ func (db *DB) migrate(schemaName string) error {
if err != nil { if err != nil {
return err return err
} }
db.logger.Infof("successfully ran migration. migrationId : %s, currentSchema : %s", i, schemaName) db.logger.Infof("localstore migration: successfully ran migration: id %v current schema: %s", i, schemaName)
} }
return nil return nil
} }
...@@ -81,7 +81,7 @@ func getMigrations(currentSchema, targetSchema string, allSchemeMigrations []mig ...@@ -81,7 +81,7 @@ func getMigrations(currentSchema, targetSchema string, allSchemeMigrations []mig
return nil, errors.New("found schema name for the second time when looking for migrations") return nil, errors.New("found schema name for the second time when looking for migrations")
} }
foundCurrent = true foundCurrent = true
db.logger.Infof("found current localstore schema. currentSchema : %s , migrateTo : %s, total migrations : %d", currentSchema, DbSchemaCurrent, len(allSchemeMigrations)-i) db.logger.Infof("localstore migration: found current localstore schema %s, migrate to %s, total migrations %d", currentSchema, DbSchemaCurrent, len(allSchemeMigrations)-i)
continue // current schema migration should not be executed (already has been when schema was migrated to) continue // current schema migration should not be executed (already has been when schema was migrated to)
case targetSchema: case targetSchema:
foundTarget = true foundTarget = true
......
...@@ -107,7 +107,7 @@ func (db *DB) updateGCItems(items ...shed.Item) { ...@@ -107,7 +107,7 @@ func (db *DB) updateGCItems(items ...shed.Item) {
err := db.updateGC(item) err := db.updateGC(item)
if err != nil { if err != nil {
db.metrics.GCUpdateError.Inc() db.metrics.GCUpdateError.Inc()
db.logger.Errorf("localstore update gc. Error : %s", err.Error()) db.logger.Errorf("localstore update gc: %v", err)
} }
} }
// if gc update hook is defined, call it // if gc update hook is defined, call it
......
...@@ -233,7 +233,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr swarm.Address, mode storage.Mod ...@@ -233,7 +233,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr swarm.Address, mode storage.Mod
// if we return the error here - it means that for example, in stream protocol peers which we sync // if we return the error here - it means that for example, in stream protocol peers which we sync
// to would be dropped. this is possible when the chunk is put with ModePutRequest and ModeSetSyncPull is // to would be dropped. this is possible when the chunk is put with ModePutRequest and ModeSetSyncPull is
// called on the same chunk (which should not happen) // called on the same chunk (which should not happen)
db.logger.Errorf("chunk not found in pull index. addr: %s", addr.String()) db.logger.Debugf("localstore: chunk with address %s not found in pull index", addr)
break break
} }
return 0, err return 0, err
...@@ -267,7 +267,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr swarm.Address, mode storage.Mod ...@@ -267,7 +267,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr swarm.Address, mode storage.Mod
// we handle this error internally, since this is an internal inconsistency of the indices // we handle this error internally, since this is an internal inconsistency of the indices
// this error can happen if the chunk is put with ModePutRequest or ModePutSync // this error can happen if the chunk is put with ModePutRequest or ModePutSync
// but this function is called with ModeSetSyncPush // but this function is called with ModeSetSyncPush
db.logger.Errorf("chunk not found in push index. addr : %s", addr.String()) db.logger.Debugf("localstore: chunk with address %s not found in push index", addr)
break break
} }
return 0, err return 0, err
...@@ -277,7 +277,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr swarm.Address, mode storage.Mod ...@@ -277,7 +277,7 @@ func (db *DB) setSync(batch *leveldb.Batch, addr swarm.Address, mode storage.Mod
if err != nil { if err != nil {
// we cannot break or return here since the function needs to // we cannot break or return here since the function needs to
// run to end from db.pushIndex.DeleteInBatch // run to end from db.pushIndex.DeleteInBatch
db.logger.Errorf("error getting tags on push sync set. uid : %d", i.Tag) db.logger.Errorf("localstore: get tags on push sync set uid %d: %v", i.Tag, err)
} else { } else {
// setting a chunk for push sync assumes the tag is not anonymous // setting a chunk for push sync assumes the tag is not anonymous
if t.Anonymous { if t.Anonymous {
......
...@@ -136,7 +136,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64) ...@@ -136,7 +136,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64)
return return
} }
db.metrics.SubscribePullIterationFailure.Inc() db.metrics.SubscribePullIterationFailure.Inc()
db.logger.Errorf("localstore pull subscription iteration. bin: %d, since: %d, until: %d. Error : %s", bin, since, until, err.Error()) db.logger.Debugf("localstore pull subscription iteration: bin: %d, since: %d, until: %d: %v", bin, since, until, err)
return return
} }
if count > 0 { if count > 0 {
...@@ -153,7 +153,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64) ...@@ -153,7 +153,7 @@ func (db *DB) SubscribePull(ctx context.Context, bin uint8, since, until uint64)
case <-ctx.Done(): case <-ctx.Done():
err := ctx.Err() err := ctx.Err()
if err != nil { if err != nil {
db.logger.Errorf("localstore pull subscription. bin: %d, since: %d, until: %d. Error : %s", bin, since, until, err.Error()) db.logger.Debugf("localstore pull subscription iteration: bin: %d, since: %d, until: %d: %v", bin, since, until, err)
} }
return return
} }
......
...@@ -18,7 +18,6 @@ package localstore ...@@ -18,7 +18,6 @@ package localstore
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"time" "time"
...@@ -80,7 +79,6 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan swarm.Chunk, stop fun ...@@ -80,7 +79,6 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan swarm.Chunk, stop fun
// set next iteration start item // set next iteration start item
// when its chunk is successfully sent to channel // when its chunk is successfully sent to channel
sinceItem = &item sinceItem = &item
db.logger.Tracef("subscribe.push. ref : %s, binId : %d", fmt.Sprintf("%x", sinceItem.Address), sinceItem.BinID)
return false, nil return false, nil
case <-stopChan: case <-stopChan:
// gracefully stop the iteration // gracefully stop the iteration
...@@ -104,7 +102,7 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan swarm.Chunk, stop fun ...@@ -104,7 +102,7 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan swarm.Chunk, stop fun
if err != nil { if err != nil {
db.metrics.SubscribePushIterationFailure.Inc() db.metrics.SubscribePushIterationFailure.Inc()
db.logger.Errorf("localstore push subscription iteration. Error : %s", err.Error()) db.logger.Debugf("localstore push subscription iteration: %v", err)
return return
} }
case <-stopChan: case <-stopChan:
...@@ -118,7 +116,7 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan swarm.Chunk, stop fun ...@@ -118,7 +116,7 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan swarm.Chunk, stop fun
case <-ctx.Done(): case <-ctx.Done():
err := ctx.Err() err := ctx.Err()
if err != nil { if err != nil {
db.logger.Errorf("localstore push subscription. Error : %s", err.Error()) db.logger.Debugf("localstore push subscription iteration: %v", err)
} }
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment