From 098ebaee2287865c56dd481d1d1efaa10cbb8d66 Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 9 Sep 2020 12:21:34 +0200 Subject: [PATCH] p2p: reduce log severity (#5338) ## Description This PR aims to reduce the amount of `Logger.Error(..)` calls. Many of these calls are benign and do not need any intervention. Went from: ``` node1 | E[2020-09-08|14:32:48.407] Connection failed @ recvRoutine (reading byte) module=p2p peer=af8747a81383f40583ae8790d2cc1f92cc7e4a35@192.167.10.4:26656 conn=MConn{192.167.10.4:26656} err="read tcp 192.167.10.3:48614->192.167.10.4:26656: read: connection reset by peer" node1 | E[2020-09-08|14:32:48.407] Stopping peer for error module=p2p peer="Peer{MConn{192.167.10.4:26656} af8747a81383f40583ae8790d2cc1f92cc7e4a35 out}" err="read tcp 192.167.10.3:48614->192.167.10.4:26656: read: connection reset by peer" node1 | E[2020-09-08|14:32:48.407] Error while stopping peer module=p2p peer=af8747a81383f40583ae8790d2cc1f92cc7e4a35@192.167.10.4:26656 err="already stopped" node1 | E[2020-09-08|14:32:48.408] MConnection flush failed module=p2p peer=af8747a81383f40583ae8790d2cc1f92cc7e4a35@192.167.10.4:26656 err="write tcp 192.167.10.3:48614->192.167.10.4:26656: use of closed network connection" ``` To: ``` node1 | E[2020-09-08|14:42:54.023] Stopping peer for error module=p2p peer="Peer{MConn{192.167.10.5:37844} e3d01d1795464a356227d0cba6567d6b94381e55 in}" err=EOF ``` Closes: #4937 --- p2p/conn/connection.go | 8 ++++---- p2p/peer.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index 70bb478d3..b5290116d 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -323,7 +323,7 @@ func (c *MConnection) flush() { c.Logger.Debug("Flush", "conn", c) err := c.bufConnWriter.Flush() if err != nil { - c.Logger.Error("MConnection flush failed", "err", err) + c.Logger.Debug("MConnection flush failed", "err", err) } } @@ -597,7 +597,7 @@ FOR_LOOP: if err == io.EOF { c.Logger.Info("Connection is closed @ recvRoutine (likely by the other side)", "conn", c) } else { - c.Logger.Error("Connection failed @ recvRoutine (reading byte)", "conn", c, "err", err) + c.Logger.Debug("Connection failed @ recvRoutine (reading byte)", "conn", c, "err", err) } c.stopForError(err) } @@ -626,7 +626,7 @@ FOR_LOOP: channel, ok := c.channelsIdx[byte(pkt.PacketMsg.ChannelID)] if !ok || channel == nil { err := fmt.Errorf("unknown channel %X", pkt.PacketMsg.ChannelID) - c.Logger.Error("Connection failed @ recvRoutine", "conn", c, "err", err) + c.Logger.Debug("Connection failed @ recvRoutine", "conn", c, "err", err) c.stopForError(err) break FOR_LOOP } @@ -634,7 +634,7 @@ FOR_LOOP: msgBytes, err := channel.recvPacketMsg(*pkt.PacketMsg) if err != nil { if c.IsRunning() { - c.Logger.Error("Connection failed @ recvRoutine", "conn", c, "err", err) + c.Logger.Debug("Connection failed @ recvRoutine", "conn", c, "err", err) c.stopForError(err) } break FOR_LOOP diff --git a/p2p/peer.go b/p2p/peer.go index 4fdb4ee57..36db3d728 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -201,7 +201,7 @@ func (p *peer) OnStop() { p.metricsTicker.Stop() p.BaseService.OnStop() if err := p.mconn.Stop(); err != nil { // stop everything and close the conn - p.Logger.Error("Error while stopping peer", "err", err) + p.Logger.Debug("Error while stopping peer", "err", err) } }