Skip to content

Commit

Permalink
Change some error logs to info (#101)
Browse files Browse the repository at this point in the history
Some loged errros are benign and might be better reported as Info.

save state Does not alter program flow, and any error is reported further up the stack.
prune client state error Does not alter program flow, error is not acted upon.
Redis returned 0 rows after select returning zero rows from a select is not necessarily an error.
get block to extend - no notarized block no error returned, program flow unaltered.
generate block - multiple tries no error returned, program flow unaltered.
sending the best block to the network no error returned, program flow unaltered.
handleNoProgress only report the last the failure as an error.
save transactions - slow no error is returned by function.
  • Loading branch information
Sriep committed Mar 16, 2021
1 parent 74581fc commit 394c1f8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions code/go/0chain.net/chaincore/chain/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ func (c *Chain) SaveChanges(ctx context.Context, b *block.Block) error {
StateChangeSizeMetric.Update(int64(len(changes)))
}
if StateSaveTimer.Count() > 100 && 2*p95 < float64(duration) {
Logger.Error("save state - slow", zap.Int64("round", b.Round), zap.String("block", b.Hash), zap.Int("block_size", len(b.Txns)), zap.Int("changes", len(changes)), zap.String("client_state", util.ToHex(b.ClientStateHash)), zap.Duration("duration", duration), zap.Duration("p95", time.Duration(math.Round(p95/1000000))*time.Millisecond))
Logger.Info("save state - slow", zap.Int64("round", b.Round), zap.String("block", b.Hash), zap.Int("block_size", len(b.Txns)), zap.Int("changes", len(changes)), zap.String("client_state", util.ToHex(b.ClientStateHash)), zap.Duration("duration", duration), zap.Duration("p95", time.Duration(math.Round(p95/1000000))*time.Millisecond))
} else {
Logger.Debug("save state", zap.Int64("round", b.Round), zap.String("block", b.Hash), zap.Int("block_size", len(b.Txns)), zap.Int("changes", len(changes)), zap.String("client_state", util.ToHex(b.ClientStateHash)), zap.Duration("duration", duration))
}
if err != nil {
Logger.Error("save state", zap.Int64("round", b.Round), zap.String("block", b.Hash), zap.Int("block_size", len(b.Txns)), zap.Int("changes", len(changes)), zap.String("client_state", util.ToHex(b.ClientStateHash)), zap.Duration("duration", duration), zap.Error(err))
Logger.Info("save state", zap.Int64("round", b.Round), zap.String("block", b.Hash), zap.Int("block_size", len(b.Txns)), zap.Int("changes", len(changes)), zap.String("client_state", util.ToHex(b.ClientStateHash)), zap.Duration("duration", duration), zap.Error(err))
}

return err
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/chaincore/chain/state_pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (c *Chain) pruneClientState(ctx context.Context) {
ps.Stage = util.PruneStateDelete
err = c.stateDB.PruneBelowVersion(pctx, newVersion)
if err != nil {
Logger.Error("prune client state error", zap.Error(err))
Logger.Info("prune client state error", zap.Error(err))
}
ps.Stage = util.PruneStateCommplete

Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/core/memorystore/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (ms *Store) iterateCollection(ctx context.Context, entityMetadata datastore
bkeys, ok := data.([]interface{})
count := len(bkeys) / 2
if count == 0 {
Logger.Error("Redis returned 0 rows after seclect")
Logger.Info("Redis returned 0 rows after seclect")
return nil
}
offset += count
Expand Down
8 changes: 4 additions & 4 deletions code/go/0chain.net/miner/protocol_round.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (mc *Chain) GetBlockToExtend(ctx context.Context, r round.RoundI) (
sort.SliceStable(pcounts, func(i, j int) bool {
return pcounts[i].Proposals > pcounts[j].Proposals
})
Logger.Error("get block to extend - no notarized block",
Logger.Info("get block to extend - no notarized block",
zap.Int64("round", r.GetRoundNumber()),
zap.Int("num_proposals", len(proposals)),
zap.Any("verification_tickets", pcounts))
Expand Down Expand Up @@ -556,7 +556,7 @@ func (mc *Chain) GenerateRoundBlock(ctx context.Context, r *Round) (*block.Block

mc.AddRoundBlock(r, b)
if generationTries > 1 {
Logger.Error("generate block - multiple tries",
Logger.Info("generate block - multiple tries",
zap.Int64("round", b.Round), zap.Int("tries", generationTries))
}
break
Expand Down Expand Up @@ -1183,7 +1183,7 @@ func (mc *Chain) handleNoProgress(ctx context.Context, round int64) {
b := r.Block
if b != nil {
if mc.GetRoundTimeoutCount() <= 10 {
Logger.Error("sending the best block to the network",
Logger.Info("sending the best block to the network",
zap.Int64("round", b.Round), zap.String("block", b.Hash),
zap.Int("rank", b.RoundRank))
}
Expand All @@ -1199,7 +1199,7 @@ func (mc *Chain) handleNoProgress(ctx context.Context, round int64) {
}
switch crt := mc.GetRoundTimeoutCount(); {
case crt < 10:
Logger.Error("handleNoProgress", zap.Any("round", mc.GetCurrentRound()), zap.Int64("count_round_timeout", crt), zap.Any("num_vrf_share", len(r.GetVRFShares())))
Logger.Info("handleNoProgress", zap.Any("round", mc.GetCurrentRound()), zap.Int64("count_round_timeout", crt), zap.Any("num_vrf_share", len(r.GetVRFShares())))
case crt == 10:
Logger.Error("handleNoProgress (no further timeout messages will be displayed)", zap.Any("round", mc.GetCurrentRound()), zap.Int64("count_round_timeout", crt), zap.Any("num_vrf_share", len(r.GetVRFShares())))
//TODO: should have a means to send an email/SMS to someone or something like that
Expand Down
2 changes: 1 addition & 1 deletion code/go/0chain.net/sharder/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (sc *Chain) StoreTransactions(ctx context.Context, b *block.Block) error {
txnSaveTimer.UpdateSince(ts)
p95 := txnSaveTimer.Percentile(.95)
if txnSaveTimer.Count() > 100 && 2*p95 < float64(duration) {
Logger.Error("save transactions - slow", zap.Any("round", b.Round), zap.String("block", b.Hash), zap.Duration("duration", duration), zap.Duration("p95", time.Duration(math.Round(p95/1000000))*time.Millisecond))
Logger.Info("save transactions - slow", zap.Any("round", b.Round), zap.String("block", b.Hash), zap.Duration("duration", duration), zap.Duration("p95", time.Duration(math.Round(p95/1000000))*time.Millisecond))
}
return nil
}
Expand Down

0 comments on commit 394c1f8

Please sign in to comment.