mysql 断开的管道_解决线上项目异常:断开的管道

标签:

项目上线运行一段时间后出现异常:

org.apache.catalina.connector.ClientAbortException: java.io.IOException: 断开的管道

at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:321)

at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:284)

at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:118)

at com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1054)

at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:953)

at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:286)

at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:106)

at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:231)

at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:174)

at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:113)

at org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver.doResolveHandlerMethodException(ExceptionHandlerExceptionResolver.java:380)

at org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver.doResolveException(AbstractHandlerMethodExceptionResolver.java:59)

at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136)

at org.springframework.web.servlet.handler.HandlerExceptionResolverComposite.resolveException(HandlerExceptionResolverComposite.java:76)

at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1222)

at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1034)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.io.IOException: 断开的管道

at sun.nio.ch.FileDispatcherImpl.write0(Native Method)

at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)

at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)

at sun.nio.ch.IOUtil.write(IOUtil.java:65)

at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)

at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134)

at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)

at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157)

at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1267)

at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:670)

at org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking(SocketWrapperBase.java:607)

at org.apache.tomcat.util.net.SocketWrapperBase.flush(SocketWrapperBase.java:597)

at org.apache.coyote.http11.Http11OutputBuffer.flushBuffer(Http11OutputBuffer.java:581)

at org.apache.coyote.http11.Http11OutputBuffer.flush(Http11OutputBuffer.java:272)

at org.apache.coyote.http11.Http11Processor.flush(Http11Processor.java:1560)

at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:283)

at org.apache.coyote.Response.action(Response.java:173)

at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:317)

... 63 common frames omitted

原因是当客户端发起请求, 由于服务端回应慢或者其他原因, 当服务端返回响应的时候, 客户端已经断开连接..

而服务端继续向断开的连接返回数据,  就发生这个异常..

网上有很多解决办法

增加超时时间:把nginx的超时时间和msyql的超时时间,各种超时时间都增加了.. 结果没变..

增加负载到多个端口:结果没变..

排查nginx的问题:

# 日志里的异常

2018/10/09 17:10:56 [error] 8937#0: *3282524 connect() failed (110: Connection timed out) while connecting to upstream, client: ****.****.****.****, server: ****.com, request: "POST /***/*** HTTP/1.1", upstream: "http://****:****/****/****", host: "****:****"

百度出是因为linux系统也有句柄限制,各种解除连接句柄限制

#查看请求连接数

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

#查看连接服务器所有IP地址

netstat -an

#查看系统最大打开文件数量

cat /proc/sys/fs/file-nr

#查看所有进程的文件打开数

lsof |wc -l

#查看某个进程打开的文件数

lsof -p pid |wc -l

# 根据访问IP统计UV

awk '{print $1}' access.log|sort | uniq -c |wc -l

# 统计访问URL统计PV

awk '{print $7}' access.log|wc -l

# 查询访问最频繁的URL

awk '{print $7}' access.log|sort | uniq -c |sort -n -k 1 -r|more

# 查询访问最频繁的IP

awk '{print $1}' access.log|sort | uniq -c |sort -n -k 1 -r|more

# 根据时间段统计查看日志

cat access.log| sed -n '/14\/Mar\/2015:21/,/14\/Mar\/2015:22/p'|more

# 临时命令增加

ulimit -u 65535;

ulimit -n 65535;

# 修改配置文件增加,永久

vi /etc/security/limits.conf

# 增加以下几行

* soft noproc 65535

* hard noproc 65535

* soft nofile 65535

* hard nofile 65535

结果没有解决问题..

排查数据库问题:中间还把数据库弄崩了一次,又重装了个mysql..

-- 查看最大连接数

show variables like '%max_connections%';

-- 更改最大连接数

set global max_connections=15000;

-- 查看所有进程

show processlist

-- 查看有没有锁表

select * from information_schema.innodb_locks

select * from information_schema.innodb_lock_waits

-- 查看数据库状态

show engine innodb status;

结果发现数据库状态里显示sql语句太慢了(测试sql语句没问题),导致锁表了

百度....

解决办法:添加索引

ALTER TABLE `表名` ADD INDEX 索引名 ( `字段`)

再次重启服务..

问题解决了...

感谢:

ps:

linux在vim环境下编辑的时候,不知道按到什么, 一部分字段变黄了, 查出是因为开启的高亮.

在command状态下,输入:noh 取消高亮.

标签:

来源: https://blog.csdn.net/qq_39349088/article/details/83001036

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值