From 88620185dbfe3717d12b47c191bd87dc333655a8 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Mon, 20 Feb 2023 14:24:30 +0800 Subject: [PATCH 1/4] feat(db): add sending timeout of zmq --- .../tron/common/logsfilter/nativequeue/NativeMessageQueue.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java index cf2fe6dce0a..a1e932bfaeb 100644 --- a/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java +++ b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java @@ -29,6 +29,7 @@ public static NativeMessageQueue getInstance() { public boolean start(int bindPort, int sendQueueLength) { context = new ZContext(); publisher = context.createSocket(SocketType.PUB); + publisher.setSendTimeOut(1000); if (Objects.isNull(publisher)) { return false; From 69deaae7b42376565c6fa7699a9cf4b94de5b8de Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Mon, 20 Feb 2023 15:18:18 +0800 Subject: [PATCH 2/4] fix(db): use constant ZMQ_SEND_TIME_OUT --- .../tron/common/logsfilter/nativequeue/NativeMessageQueue.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java index a1e932bfaeb..0a40bd18ecd 100644 --- a/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java +++ b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java @@ -11,6 +11,7 @@ public class NativeMessageQueue { private static final int DEFAULT_BIND_PORT = 5555; private static final int DEFAULT_QUEUE_LENGTH = 1000; + private static final int ZMQ_SEND_TIME_OUT = 1_000; private static NativeMessageQueue instance; private ZContext context = null; private ZMQ.Socket publisher = null; @@ -29,7 +30,7 @@ public static NativeMessageQueue getInstance() { public boolean start(int bindPort, int sendQueueLength) { context = new ZContext(); publisher = context.createSocket(SocketType.PUB); - publisher.setSendTimeOut(1000); + publisher.setSendTimeOut(ZMQ_SEND_TIME_OUT); if (Objects.isNull(publisher)) { return false; From 6b2a7f9dc54d3ccbb1a2b8701488f8c4f18910f3 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Mon, 20 Feb 2023 17:12:54 +0800 Subject: [PATCH 3/4] fix(net): optimize log of P2pEventHandlerImpl --- .../src/main/java/org/tron/core/net/P2pEventHandlerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/org/tron/core/net/P2pEventHandlerImpl.java b/framework/src/main/java/org/tron/core/net/P2pEventHandlerImpl.java index f6a01b1cf95..66774a216f2 100644 --- a/framework/src/main/java/org/tron/core/net/P2pEventHandlerImpl.java +++ b/framework/src/main/java/org/tron/core/net/P2pEventHandlerImpl.java @@ -222,10 +222,10 @@ private void processException(PeerConnection peer, TronMessage msg, Exception ex break; } if (type.equals(P2pException.TypeEnum.BAD_MESSAGE)) { - logger.error("Message from {} process failed, {} \n type: {}", + logger.error("Message from {} process failed, {} \n type: ({})", peer.getInetSocketAddress(), msg, type, ex); } else { - logger.warn("Message from {} process failed, {} \n type: {}, detail: {}", + logger.warn("Message from {} process failed, {} \n type: ({}), detail: {}", peer.getInetSocketAddress(), msg, type, ex.getMessage()); } } else { From 14c1c80bc08861d6ce4bff424f23472e43e26665 Mon Sep 17 00:00:00 2001 From: jiangyuanshu <317787106@qq.com> Date: Mon, 20 Feb 2023 17:41:27 +0800 Subject: [PATCH 4/4] fix(db): reorder setSendTimeOut function --- .../tron/common/logsfilter/nativequeue/NativeMessageQueue.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java index 0a40bd18ecd..e79a0973c1a 100644 --- a/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java +++ b/framework/src/main/java/org/tron/common/logsfilter/nativequeue/NativeMessageQueue.java @@ -30,12 +30,11 @@ public static NativeMessageQueue getInstance() { public boolean start(int bindPort, int sendQueueLength) { context = new ZContext(); publisher = context.createSocket(SocketType.PUB); - publisher.setSendTimeOut(ZMQ_SEND_TIME_OUT); if (Objects.isNull(publisher)) { return false; } - + publisher.setSendTimeOut(ZMQ_SEND_TIME_OUT); if (bindPort == 0 || bindPort < 0) { bindPort = DEFAULT_BIND_PORT; }