今天现场报了以下问题:
Cannot forward to error page for request [/order/search] as the response has already been committed. As a result,
the response may have the wrong status code. If your application is running on WebSphere Application Server you may be
able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false"
从这个错误信息中,我们可以看到,信息提示我们无法前进到错误页面,在请求:/order/search这个url时。后面又提示我们,可以返回了一个错误的状态编码,然后提示我们去设置一个环境变量。
从这个情况中,我们可以预想到以下几种原因:
1.forward的url关联的视图存在问题,导致无法展现
2.forward的url错误
3.在执行这个请求中,出现了相关的逻辑错误,导致返回错误的状态码
第一个和第二个错误很好排查,但是第三个错误,需要查看该url关联的所有逻辑,找出导致出现错误码的原因。
我的现场错误还出现了以下信息:
2018-11-01T06:46:30.891Z,paas-03,org.apache.catalina.connector.ClientAbortException: java.io.IOException: Connection reset by peer 2018-11-01T06:46:30.892Z,paas-03,#011at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) ~[catalina.jar:8.5.13] 2018-11-01T06:46:30.893Z,paas-03,#011at net.bull.javamelody.internal.web.CounterResponseStream.write(CounterResponseStream.java:81) ~[javamelody-core-1.68.0.jar:1.68.0] 2018-11-01T06:46:30.893Z,paas-03,#011at com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1047) ~[jackson-core-2.8.7.jar:2.8.7] 2018-11-01T06:46:30.893Z,paas-03,#011at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:285) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE] 2018-11-01T06:46:30.894Z,paas-03,#011at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE] 2018-11-01T06:46:30.894Z,paas-03,#011at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:132) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE] 2018-11-01T06:46:30.895Z,paas-03,#011at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[servlet-api.jar:na] 2018-11-01T06:46:30.897Z,paas-03,#011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [catalina.jar:8.5.13] 2018-11-01T06:46:30.899Z,paas-03,#011at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 2018-11-01T06:46:30.900Z,paas-03,#011at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.13] 2018-11-01T06:46:30.900Z,paas-03,#011at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.13] 2018-11-01T06:46:30.900Z,paas-03,#011at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) [catalina.jar:8.5.13] 2018-11-01T06:46:30.901Z,paas-03,#011at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) [tomcat-coyote.jar:8.5.13] 2018-11-01T06:46:30.901Z,paas-03,#011at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.13] 2018-11-01T06:46:30.901Z,paas-03,#011at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) [tomcat-coyote.jar:8.5.13] 2018-11-01T06:46:30.901Z,paas-03,#011at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.13] 2018-11-01T06:46:30.902Z,paas-03,#011at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_102] 2018-11-01T06:46:30.903Z,paas-03,#011at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101) ~[tomcat-coyote.jar:8.5.13] 2018-11-01T06:46:30.904Z,paas-03,#011at org.apache.coyote.Response.doWrite(Response.java:518) ~[tomcat-coyote.jar:8.5.13]
“Connection reset by peer”表示当前服务器接受到了通信对端发送的TCP RST信号,即通信对端已经关闭了连接,通过RST信号希望接收方关闭连接。
很明显相关联的服务,主动关闭了连接,我寻思这可能存在以下情况:
1.关联服务出现错误或者崩溃
2.关联服务长时间未返回,比如数据查询时间过长,但设置了超时时间,超过规定时间关闭连接
我看下关联服务的日志,发现有sql查询时间过长的情况,大概40秒,试着增加过滤条件,sql查询时间变少了,上述的bug就不出现了。