-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle exception in NIO loop to avoid abrupt termination #611
Comments
Thanks for reporting this. Could you please upgrade to the latest release (5.7.0), provide steps to reproduce, and logs? Thanks! |
OK, found it, there's no error handling here, so an exception can indeed make the whole NIO thread stops: registration.state.getChannel().register(selector, operations, registration.state); This is actually already handled in the write part: try {
if (writeRegistration.state.getChannel().isOpen()) {
writeRegistration.state.getChannel().register(writeSelector, operations, writeRegistration.state);
writeRegistered = true;
}
} catch (Exception e) {
// can happen if the channel has been closed since the operation has been enqueued
LOGGER.info("Error while registering socket channel for write: {}", e.getMessage());
} We just have to do the same. This fixes the second item you mentioned, what exactly do you mean by NIO epoll bug, not handled in the first item? |
Thanks, man, good job. @acogoluegnes |
Netty framework has a solution for nio epoll bug. When it detects that bug happen, a new selector will be created. All channels registered to the old selector will register to the new one. |
I pushed a fix. The NIO epoll bug is marked to have been solved more than a decade ago in the JDK, so my advice would be to upgrade to a recent JVM to avoid it. |
I'm using JDK 1.8.0_181, I didn't encounter NIO epoll bug, and yes, It was marked as fixed, but it's not actually. I found a few cases under jdk1.8 through google. Doesn't matter, I think I am lucky enough. |
@hailin84 There's a 5.7.1 snapshot available with the fix: https://oss.sonatype.org/content/repositories/snapshots/com/rabbitmq/amqp-client/5.7.1-SNAPSHOT/ Can you give it a try? |
rabbitmq-nio thread terminated unexpectedly
I am using rabbitmq in my java system. When I try to use nio, I got rabbitmq-nio thread terminated unexpectedly. I review the code, there must be two problems(NioLoop.run):
Here is my exception stacktrace log:
Thanks for your help.
The text was updated successfully, but these errors were encountered: