From a52e016c22de2269fcc7362f33317cebfa7e8e4c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 13 Jan 2020 16:44:12 +0300 Subject: [PATCH 1/3] cli/server: disable sampling completely It's not safe, we don't want to lose messages and we don't have that many of them to try to figure out what is the better value than the default 100. --- cli/server/server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/server/server.go b/cli/server/server.go index 87cc30a02..42a5a7259 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -134,6 +134,7 @@ func handleLoggingParams(ctx *cli.Context, cfg config.ApplicationConfiguration) cc.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder cc.Encoding = "console" cc.Level = zap.NewAtomicLevelAt(level) + cc.Sampling = nil if logPath := cfg.LogPath; logPath != "" { if err := io.MakeDirForFile(logPath, "logger"); err != nil { From b5f234ddef26a3bc4f6f057090dd60946068a262 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 13 Jan 2020 16:45:36 +0300 Subject: [PATCH 2/3] rpc: make rpc request logging at Debug level Makes no sense polluting logs with Info. It also affects benchmarking. --- pkg/rpc/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index 83c46e52d..3bc5cd451 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -99,7 +99,7 @@ func (s *Server) requestHandler(w http.ResponseWriter, httpRequest *http.Request } func (s *Server) methodHandler(w http.ResponseWriter, req *Request, reqParams Params) { - s.log.Info("processing rpc request", + s.log.Debug("processing rpc request", zap.String("method", req.Method), zap.String("params", fmt.Sprintf("%v", reqParams))) From 2192b6602aaa1b73ad037247d42cd5342561511c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 13 Jan 2020 16:56:59 +0300 Subject: [PATCH 3/3] network: fix logic and logging for sendVersion() errors It doesn't make sense trying to read from a broken connection and the disconnect is to be logger from the server on unregistration. --- pkg/network/tcp_transport.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/network/tcp_transport.go b/pkg/network/tcp_transport.go index 9739efc9b..58896156e 100644 --- a/pkg/network/tcp_transport.go +++ b/pkg/network/tcp_transport.go @@ -82,22 +82,22 @@ func (t *TCPTransport) handleConn(conn net.Conn) { t.server.register <- p // When a new peer is connected we send out our version immediately. - if err := t.server.sendVersion(p); err != nil { - t.log.Error("error on sendVersion", zap.Stringer("addr", p.RemoteAddr()), zap.Error(err)) - } - r := io.NewBinReaderFromIO(p.conn) - for { - msg := &Message{} - err = msg.Decode(r) + err = t.server.sendVersion(p) + if err == nil { + r := io.NewBinReaderFromIO(p.conn) + for { + msg := &Message{} + err = msg.Decode(r) - if err == payload.ErrTooManyHeaders { - t.log.Warn("not all headers were processed") - r.Err = nil - } else if err != nil { - break - } - if err = t.server.handleMessage(p, msg); err != nil { - break + if err == payload.ErrTooManyHeaders { + t.log.Warn("not all headers were processed") + r.Err = nil + } else if err != nil { + break + } + if err = t.server.handleMessage(p, msg); err != nil { + break + } } } t.server.unregister <- peerDrop{p, err}