clean up logging
This commit is contained in:
parent
ef391d8d31
commit
8371344756
@ -56,7 +56,7 @@ func stateSnapshot() {
|
||||
recoveryFile := viper.GetString(snapshot.SNAPSHOT_RECOVERY_FILE_TOML)
|
||||
if recoveryFile == "" {
|
||||
recoveryFile = fmt.Sprintf("./%d_snapshot_recovery", height)
|
||||
logWithCommand.Infof("no recovery file set, creating default: %s", recoveryFile)
|
||||
logWithCommand.Infof("no recovery file set, using default: %s", recoveryFile)
|
||||
}
|
||||
|
||||
pub, err := snapshot.NewPublisher(mode, config)
|
||||
|
@ -81,8 +81,6 @@ type SnapshotParams struct {
|
||||
}
|
||||
|
||||
func (s *Service) CreateSnapshot(params SnapshotParams) error {
|
||||
log.Infof("createSnapshot BEGIN %v", params)
|
||||
|
||||
// extract header from lvldb and publish to PG-IPFS
|
||||
// hold onto the headerID so that we can link the state nodes to this header
|
||||
log.Infof("Creating snapshot at height %d", params.Height)
|
||||
@ -94,36 +92,30 @@ func (s *Service) CreateSnapshot(params SnapshotParams) error {
|
||||
|
||||
log.Infof("head hash: %s head height: %d", hash.Hex(), params.Height)
|
||||
|
||||
log.Infof("publish header")
|
||||
err := s.ipfsPublisher.PublishHeader(header)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infof("opening trie...")
|
||||
tree, err := s.stateDB.OpenTrie(header.Root)
|
||||
log.Infof("opened trie")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
headerID := header.Hash().String()
|
||||
s.tracker = newTracker(s.recoveryFile, int(params.Workers))
|
||||
s.tracker.captureSignal()
|
||||
|
||||
log.Infof("after goroutines start")
|
||||
|
||||
var iters []trie.NodeIterator
|
||||
// attempt to restore from recovery file if it exists
|
||||
log.Infof("restoring iterators from recovery file...")
|
||||
iters, err = s.tracker.restore(tree)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("restore error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
if iters != nil {
|
||||
log.Infof("restored iterators; count: %d", len(iters))
|
||||
log.Debugf("restored iterators; count: %d", len(iters))
|
||||
if params.Workers < uint(len(iters)) {
|
||||
return fmt.Errorf(
|
||||
"number of recovered workers (%d) is greater than number configured (%d)",
|
||||
@ -131,17 +123,13 @@ func (s *Service) CreateSnapshot(params SnapshotParams) error {
|
||||
)
|
||||
}
|
||||
} else { // nothing to restore
|
||||
log.Infof("no iterators to restore")
|
||||
log.Debugf("no iterators to restore")
|
||||
if params.Workers > 1 {
|
||||
log.Infof("creating %d subtrie iterators...", params.Workers)
|
||||
iters = iter.SubtrieIterators(tree, params.Workers)
|
||||
log.Infof("created %d subtrie iterators", params.Workers)
|
||||
} else {
|
||||
log.Infof("creating node iterators")
|
||||
iters = []trie.NodeIterator{tree.NodeIterator(nil)}
|
||||
}
|
||||
for i, it := range iters {
|
||||
log.Infof("tracked iterator %d", i)
|
||||
iters[i] = s.tracker.tracked(it)
|
||||
}
|
||||
}
|
||||
@ -153,8 +141,6 @@ func (s *Service) CreateSnapshot(params SnapshotParams) error {
|
||||
}
|
||||
}()
|
||||
|
||||
log.Infof("num iters %d", len(iters))
|
||||
|
||||
if len(iters) > 0 {
|
||||
return s.createSnapshotAsync(iters, headerID)
|
||||
} else {
|
||||
|
@ -72,7 +72,7 @@ func (tr *iteratorTracker) tracked(it trie.NodeIterator) (ret *trackedIter) {
|
||||
|
||||
// dumps iterator path and bounds to a text file so it can be restored later
|
||||
func (tr *iteratorTracker) dump() error {
|
||||
log.Info("Dumping recovery state to: ", tr.recoveryFile)
|
||||
log.Debug("Dumping recovery state to: ", tr.recoveryFile)
|
||||
var rows [][]string
|
||||
for it, _ := range tr.started {
|
||||
var endPath []byte
|
||||
@ -103,6 +103,7 @@ func (tr *iteratorTracker) restore(tree state.Trie) ([]trie.NodeIterator, error)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
log.Debug("Restoring recovery state from: ", tr.recoveryFile)
|
||||
defer file.Close()
|
||||
in := csv.NewReader(file)
|
||||
in.FieldsPerRecord = 2
|
||||
|
Loading…
Reference in New Issue
Block a user