javaee / grizzly

Writing scalable server applications in the Java™ programming language has always been difficult. Before the advent of the Java New I/O API (NIO), thread management issues made it impossible for a server to scale to thousands of users. The Grizzly NIO framework has been designed to help developers to take advantage of the Java™ NIO API.
https://javaee.github.io/grizzly/
Other
221 stars 60 forks source link

Endless loop at TCPNIOTransport.read when closing channel failed #1758

Closed glassfishrobot closed 9 years ago

glassfishrobot commented 9 years ago

We got an endless loop sometimes when there was network problem, as the trace stack shown below. I dived into source code, found there was bug in NIOConnection.close0(416). It set closeTypeFlag NOT_NULL first and then tried to close the connection. If IOException thrown when "transport.closeConnection(NIOConnection.this)", the connection won't be closed FOREVER and lead to an endless loop in TCPNIOTransport.read. I think closeTypeFlag should be set null when IOException caught.

"Grizzly(1) SelectorRunner" daemon prio=10 tid=0x00007f7e013da000 nid=0x1c95 runnable [0x00007f7dc935a000] java.lang.Thread.State: RUNNABLE at java.lang.Throwable.fillInStackTrace(Native Method)

glassfishrobot commented 9 years ago

Reported by godeyes

glassfishrobot commented 9 years ago

oleksiys said: Hmm, that's interesting, do you know what kind of Exception is thrown from Transport.closeConnection(...)? Because 1st thing we do there is closing NIO Channel, so I'd expect it should work, otherwise it sounds like NIO bug.

Thank you.

glassfishrobot commented 9 years ago

godeyes said: Thank you for your reply. We didn't catch the exception in the log. But AbstractInterrruptibleChannnel.close() of NIO called by Transport.closeConnection(...) is declared to throw IOException. So, I don't think this close() will always work well.

glassfishrobot commented 9 years ago

oleksiys said: Can you pls. lower the logging level for org.glassfish.grizzly.nio.transport.TCPNIOTransport to FINEST? It will dump the exception when closeConnection is invoked.

I'd really like to know what kind of exception is that, if it's some Interrupted-like exception - it's one thing and in that case we'll have to find out who interrupts the thread... but if it's some different Exception - we'll probably need to investigate more carefully.

Thank you.

glassfishrobot commented 9 years ago

godeyes said: We encountered this issue when there were some network problems. After that, I tried to reproduce this issue but failed. Maybe we could suspend this until the problem reproduces, since we can get more information and logs then.

Thanks.

glassfishrobot commented 9 years ago

oleksiys said: It would be great! Thank you!

glassfishrobot commented 9 years ago

@rlubke said: Closing this for now per the submitter. Re-open if the issue can be reproduced.

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA GRIZZLY-1758

glassfishrobot commented 9 years ago

Marked as cannot reproduce on Friday, October 16th 2015, 1:26:56 pm