Merge pull request #274 from filecoin-project/misc/better-log

Improve logs and error messages
This commit is contained in:
Łukasz Magiera 2019-10-03 22:01:13 +02:00 committed by GitHub
commit c45944627a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View File

@ -349,7 +349,7 @@ func (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, coun
} }
// TODO: What if we have no peers (and err is nil)? // TODO: What if we have no peers (and err is nil)?
return nil, xerrors.Errorf("GetChainMessages failed with all peers: %w", err) return nil, xerrors.Errorf("GetChainMessages failed with all peers(%d): %w", len(peers), err)
} }
func bstsToFullTipSet(bts *BSTipSet) (*store.FullTipSet, error) { func bstsToFullTipSet(bts *BSTipSet) (*store.FullTipSet, error) {

View File

@ -99,7 +99,7 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) {
log.Debug("got block from ourselves") log.Debug("got block from ourselves")
if err := syncer.Sync(fts); err != nil { if err := syncer.Sync(fts); err != nil {
log.Errorf("failed to sync our own block: %s", err) log.Errorf("failed to sync our own block: %+v", err)
} }
return return
@ -111,7 +111,7 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) {
go func() { go func() {
if err := syncer.Sync(fts); err != nil { if err := syncer.Sync(fts); err != nil {
log.Errorf("sync error: %s", err) log.Errorf("sync error: %+v", err)
} }
}() }()
} }
@ -532,7 +532,7 @@ loop:
// Most likely our peers aren't fully synced yet, but forwarded // Most likely our peers aren't fully synced yet, but forwarded
// new block message (ideally we'd find better peers) // new block message (ideally we'd find better peers)
log.Error("failed to get blocks: ", err) log.Errorf("failed to get blocks: %+v", err)
// This error will only be logged above, // This error will only be logged above,
return nil, xerrors.Errorf("failed to get blocks: %w", err) return nil, xerrors.Errorf("failed to get blocks: %w", err)
@ -570,9 +570,9 @@ loop:
func (syncer *Syncer) syncMessagesAndCheckState(headers []*types.TipSet) error { func (syncer *Syncer) syncMessagesAndCheckState(headers []*types.TipSet) error {
syncer.syncState.SetHeight(0) syncer.syncState.SetHeight(0)
return syncer.iterFullTipsets(headers, func(fts *store.FullTipSet) error { return syncer.iterFullTipsets(headers, func(fts *store.FullTipSet) error {
log.Debugf("validating tipset (heigt=%d, size=%d)", fts.TipSet().Height(), len(fts.TipSet().Cids())) log.Debugw("validating tipset", "height", fts.TipSet().Height(), "size", len(fts.TipSet().Cids()))
if err := syncer.ValidateTipSet(context.TODO(), fts); err != nil { if err := syncer.ValidateTipSet(context.TODO(), fts); err != nil {
log.Errorf("failed to validate tipset: %s", err) log.Errorf("failed to validate tipset: %+v", err)
return xerrors.Errorf("message processing failed: %w", err) return xerrors.Errorf("message processing failed: %w", err)
} }
@ -625,11 +625,9 @@ func (syncer *Syncer) iterFullTipsets(headers []*types.TipSet, cb func(*store.Fu
bstip := bstips[len(bstips)-(bsi+1)] bstip := bstips[len(bstips)-(bsi+1)]
fts, err := zipTipSetAndMessages(blks, this, bstip.BlsMessages, bstip.SecpkMessages, bstip.BlsMsgIncludes, bstip.SecpkMsgIncludes) fts, err := zipTipSetAndMessages(blks, this, bstip.BlsMessages, bstip.SecpkMessages, bstip.BlsMsgIncludes, bstip.SecpkMsgIncludes)
if err != nil { if err != nil {
log.Warn("zipping failed: ", err, bsi, i) log.Warnw("zipping failed", "error", err, "bsi", bsi, "i", i,
log.Warn("height: ", this.Height()) "height", this.Height(), "bstip-height", bstip.Blocks[0].Height,
log.Warn("bstip height: ", bstip.Blocks[0].Height) "bstips", bstips, "next-height", i+batchSize)
log.Warn("bstips: ", bstips)
log.Warn("next height: ", i+batchSize)
return xerrors.Errorf("message processing failed: %w", err) return xerrors.Errorf("message processing failed: %w", err)
} }
@ -655,7 +653,7 @@ func persistMessages(bs bstore.Blockstore, bst *BSTipSet) error {
for _, m := range bst.BlsMessages { for _, m := range bst.BlsMessages {
//log.Infof("putting BLS message: %s", m.Cid()) //log.Infof("putting BLS message: %s", m.Cid())
if _, err := store.PutMessage(bs, m); err != nil { if _, err := store.PutMessage(bs, m); err != nil {
log.Error("failed to persist messages: ", err) log.Errorf("failed to persist messages: %+v", err)
return xerrors.Errorf("BLS message processing failed: %w", err) return xerrors.Errorf("BLS message processing failed: %w", err)
} }
} }
@ -665,7 +663,7 @@ func persistMessages(bs bstore.Blockstore, bst *BSTipSet) error {
} }
//log.Infof("putting secp256k1 message: %s", m.Cid()) //log.Infof("putting secp256k1 message: %s", m.Cid())
if _, err := store.PutMessage(bs, m); err != nil { if _, err := store.PutMessage(bs, m); err != nil {
log.Error("failed to persist messages: ", err) log.Errorf("failed to persist messages: %+v", err)
return xerrors.Errorf("secp256k1 message processing failed: %w", err) return xerrors.Errorf("secp256k1 message processing failed: %w", err)
} }
} }