Details
Description
Dear Jetty developers,
We found issue in our project which appear to be jetty related. Can you help to understand what we can do regarding it and is it possible to solve it?
In short we have a simple Axis webservice hosting in Jetty (6.1.5). Our customers use C# to connect and retrieve data from our service. While the client retrieves data from our service, a lot of requests, sometimes, absolutely unpredictably Jetty throws an exception (it is visible only if debug set up for Jetty).
2009-04-03 14:51:20.254::WARN: /services/MyService
java.nio.channels.CancelledKeyException
at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:55)
at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:59)
at org.mortbay.io.nio.SelectChannelEndPoint.updateKey(SelectChannelEndPoint.java:311)
at org.mortbay.io.nio.SelectChannelEndPoint.blockWritable(SelectChannelEndPoint.java:265)
at org.mortbay.jetty.AbstractGenerator$Output.blockForOutput(AbstractGenerator.java:540)
at org.mortbay.jetty.AbstractGenerator$Output.flush(AbstractGenerator.java:567)
at org.mortbay.jetty.HttpConnection$Output.flush(HttpConnection.java:907)
at org.mortbay.jetty.AbstractGenerator$Output.write(AbstractGenerator.java:628)
at org.mortbay.jetty.AbstractGenerator$Output.write(AbstractGenerator.java:575)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:263)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:190)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
at java.io.BufferedWriter.write(BufferedWriter.java:212)
at java.io.Writer.write(Writer.java:140)
at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:277)
at org.apache.axis.Message.writeTo(Message.java:440)
at org.apache.axis.transport.http.AxisServlet.sendResponse(AxisServlet.java:1018)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:895)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.handler.StatisticsHandler.handle(StatisticsHandler.java:89)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:309)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
2009-04-03 14:51:20.255::DEBUG: Response already committed for handling java.nio.channels.CancelledKeyException
After this exception happens, client recieves incomplete responce, XML we sent from server arrives interrupted with EOF. From network traffic point of view jetty sends responce with two flags set up PSH and ACK (usually it sends only ACKs).
After this problem was found we tried latest version of jetty (6.1.16) and happily found that the bug is not reproduced with this Jetty version.
Though after some time we noticed that file handles are increasing slowly (after one day by usual load we saw about 2K file handles, while 6.1.5 version keeps on 300 file handles). So now we are little bit puzzled which Jetty version to use. I tried version 6.1.11 and the bug with interrupted request is still reproduced, while handles are not growing (behaves same way as 6.1.5).
There are several weirdies about the handles growing:
We had the handles leak before and java was crashing when the number reached some critical value (~ 1K or 2K). For sure now we have more and system continue working with no problems.
The handles themselves are shown in lsof command somewhat strange
lsof -p <process-pid>
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
//some ordinary files
java 10426 zrinst mem REG 253,3 111970 34599 /data/zephyr/jdk/jdk1.6.0_11/jre/lib/amd64/libnet.so
...
//some IPv files/sockets
java 10426 zrinst 216u IPv6 2730598894 TCP *:opsession-srvr (LISTEN)
...
//and the ones which are growing
java 10426 zrinst 765u unix 0xffff81041a651a40 2730601387 socket
java 10426 zrinst 766u unix 0xffff81041a651a40 2730601387 socket
java 10426 zrinst 767u unix 0xffff81041a651a40 2730601387 socket
java 10426 zrinst 768u unix 0xffff81041a651a40 2730601387 socket
java 10426 zrinst 769u unix 0xffff81041a651a40 2730601387 socket
java 10426 zrinst 770u unix 0xffff81041a651a40 2730601387 socket
Is it possible to understand what is wrong and propose Jetty version to use
I can provide more information regarding the issue if you need
Jetty 6.1.16 is definitely the version to use.
I have not seen any evidence of FD usage growth with 6.1.16, at least not to the level of being a problem.
what does netstat report? Are there connections to match those FDs?