zl程序教程

您现在的位置是:首页 >  其他

当前栏目

netstat -ano输出中的ESTABLISHED off

输出 netstat Off
2023-09-27 14:28:34 时间

  今天,我们性能测试的环境出现个奇怪现象,通过oci direct load回库的进程似乎僵死了,应用端cpu 200%(两个线程在跑,一个是一直在ocidirectload没反应,另外一个是正在sem_trywait),如下:

  oracle服务器端从一开始收到请求并执行完成之后,就没有反应了,也没有等待事件,session状态为inactive(这没有任何副作用),ash中在此之后就没有这个session的任何记录了,多个分库都是一样的现象(比较坑的是,这个动态库是我们研发中心开发的,代码不open)。

  目前问题还没有时间查,主要怀疑可能是表空间满,今天又出来了,不同的位置,但是内部都是在调用oci direct load的逻辑没有正常返回结果码的问题,经测试,不是这个问题。今天的异常如下:

   继续查看了各服务器到数据库的网络连接状态,oracle服务器节点都是keepalived。但是应用端为off,如下:

  输出各列的含义如下:

  以前都是等待超时之类的,off的状态网上介绍也比较少。它是通过-o选项出来的,也就是网络计时器。经仔细查找,off的含义如下:

keepalive - when the keepalive timer is ON for the socket
on - when the retransmission timer is ON for the socket
off - none of the above is ON

如上述所示,Recv-Q Send-Q 都是0。man也没有写timer的含义。所以这个问题基本上推测就在Timer身上。ss上可以看到非establish off状态的很多连接上也可能有定时器,如下:

timer列的定义为:
timer:(<timer_name>,<expire_time>,<retrans>) timer:(keepalive,30sec,0)

 共有五种类型的tcp timer,如下:

  • on : means one of these timers: TCP retrans timer(也称为Time out timer), TCP early retrans timer and tail loss probe timer
  • keepalive: tcp keep alive timer,默认为7200秒,超过后会每隔75秒发送10次探测,超过后服务器会关闭连接。用于识别死连接,其机制为When a TCP connection on a routing device is idle for too long, the device sends a TCP keepalive packet to the peer with only the Acknowledgment (ACK) flag turned on. If a response packet (a TCP ACK packet) is not received after the device sends a specific number of probes, the connection is considered dead and the device initiating the probes frees resources used by the TCP connection.
  • timewait: timewait stage timer
  • persist: zero window probe timer
  • unknown: none of the above timers

  连接状态转换图(它们都可以体现在netstat中)如下:

 

参考:

https://superuser.com/questions/240456/how-to-interpret-the-output-of-netstat-o-netstat-timers

https://github.com/netty/netty/issues/7292

https://dashdash.io/8/ss   作为nestat的代替品出现,包含了比netstat更多的信息。

windows/linux/aix各平台keepalive优化(默认值通常不合理) https://www.veritas.com/support/en_US/article.100028680

TCP Keepalive Timer相关的参考,https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/