我们正在使用 jgroups 通过我们的集群同步几个 java 对象。目前我们只有两台服务器,我们使用 TCP 协议。我们为同步配置了一个 tcp 端口(42812)。
我们发现了以下问题:当服务器运行一段时间,1 小时到 3 小时,那么内存使用量就会增加很多。这就是我们进行堆转储并在两台服务器上发现以下泄漏嫌疑人的原因:
The thread java.lang.Thread @ 0x5ff35fdd8 Connection.Receiver [11.63.99.51:42813
- 11.63.99.51:42813],userNotificationCounterSync,hjad-gts4-de16-38376 keeps local
variables with total size 1.650.814.560 (38,04%) bytes.
The memory is accumulated in one instance of "byte[]" loaded by "".
The stacktrace of this Thread is available. See stacktrace.
当我们进行 tcp 转储时,我们只看到通过 42813 端口发送的 syn ack 包,但这是在内存增加之后。所以在我们看来,服务器正在通过未配置的端口接收消息并且不处理它们。内存使用量永远不会超过 1.650.814.560 字节,并且同步的容器是同步的,所以我们没有同步问题。我们在 spring xml 配置中将 JChannel 配置为 port_range 为 0:
TCP(bind_port=12812;
port_range=0;
recv_buf_size=130k;
send_buf_size=130k;
tcp_nodelay=true;
enable_bundling=false;)
:TCPPING(initial_hosts=server1[42812],server2[42812])
:MERGE2:FD_SOCK:VERIFY_SUSPECT:pbcast.NAKACK(use_mcast_xmit=false;retransmit_timeout=300,600,1200,2400,4800;discard_delivered_msgs=true;)
:UNICAST:pbcast.STABLE(stability_delay=1000;desired_avg_gossip=50000;max_bytes=400000;)
:FRAG:pbcast.GMS(print_local_addr=true;join_timeout=3000;view_bundling=true;):pbcast.STATE
在我们看来,对于这种配置,节点不应通过端口 42813 进行通信。
Connection.Receiver 怎么可能通过这个端口接收这么多数据,为什么它没有被处理?