You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
100% CPU (core) on NioClientSocketPipelineSink#Boss #535
Managed to get into this state twice while running my test suite, second time managed to put a breakpoint and debug it a bit. Sadly, haven't managed to repro it since (working on it).
Some details, seems like the select(10) always returns immediately, returning 0, but there is a single key in the selector. keys. Sadly, did not check the shutdown flag or the executor service isShutdown flag, but I suspect the executor service would have been shut down, as this is part of a test suite that starts and stops all the time, and somehow it got into this state while it should have "exited".
I know, not much info, but was thinking that I would open this just in case. Still trying to repro this for the past few days, no luck yet.
int selectedKeyCount = selector.select(10) returns immediatly with 0.
selector.keys() is not empty with 1 key, the details for the key at: channel (SockeyChannel[closed]), index 0, interestedOps 8, readyOps 0, valid true.
The ((ExecutorService) bossExecutor).isShutdown() is true (i.e. it was properly shutdown)
It seems like its getting into a spin in this case, where it always keeps on retrying. This might happen because of an Unexpected exception in the selector loop happening with a CancelledKeyException (still trying to track this one down), sadly don't have the stack trace for it.
Note, I don't believe that this happens only on close of the boss, as I have seen users reporting the CancelledKeyException even when no bootstrap is actually being closed.
Here is the CancelledKeyException stack trace (note, netty is embedded):
12:24:58,006 WARN New I/O client boss #11 NioClientSocketPipelineSink:internalWarn:105 - Unexpected exception in the selector loop.
java.nio.channels.CancelledKeyException
at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73)
at sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:87)
at java.nio.channels.SelectionKey.isConnectable(SelectionKey.java:336)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:353)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
@normanmaurer will do today, it took me a couple of days to get to when it happens..., so hard to say when it stops happening, but, looking at your fix, it looks good!
@kimchy just did some minor cleanup/change to make it "more compact". So please use this one... I'm awaiting your feedback! And thanks again for reporting!
@normanmaurer the fix is great, I suggest we push it, its important. I did though get into the same test once (sadly) with 100% CPU as described in the initial issue description, not much more info yet. I am still trying to figure out if its related to trying to release the bootstrap with concurrency problems around trying to open a connection at the same time, or its not really related to releasing a bootstrap, and its simply in a shutdown state because the test released it. Maybe @trustin can chip in...
@normanmaurer I am going to play a bit in my usecase, and make sure that no client connection might be initiated while shutting down the client bootstrap, will see if it helps, but +1 on pushing your fix for now.
@normanmaurer the fix is great, I suggest we push it, its important. I did though get into the same test once (sadly) with 100% CPU as described in the initial issue description, not much more info yet. I am still trying to figure out if its related to trying to release the bootstrap with concurrency problems around trying to open a connection at the same time, or its not really related to releasing a bootstrap, and its simply in a shutdown state because the test released it. Maybe @trustin can chip in...
—
Reply to this email directly or view it on GitHub.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/535#issuecomment-7993295.
Not sure if that will help, what happens is that you get into a spin in the client Boos thread with all the mentioned state explained in the issue dec (current keys, and so on). A thread dump will just show that its in the middle of doing something in the client boss thread.
@normanmaurer I was suspecting that, but I never managed to prove that this was the problem, since once I managed to recreate it, the select returns 0, but the seclectKeys was empty, though, I suspect, the weird combination of select return 0 yet having selectedKeys might be applied only for the first iteration and then we get into the constant state described above.
@normanmaurer I was suspecting that, but I never managed to prove that this was the problem, since once I managed to recreate it, the select returns 0, but the seclectKeys was empty, though, I suspect, the weird combination of select return 0 yet having selectedKeys might be applied only for the first iteration and then we get into the constant state described above.
—
Reply to this email directly or view it on GitHub.
Great that you were able to repro it!, it takes me some time to get to a state where it happens. Wondering, with the change you made, if it shouldn't be applied to other places where the return value of the select method is used, and process the selectedKeys regardless of the return value.
Great that you were able to repro it!, it takes me some time to get to a state where it happens. Wondering, with the change you made, if it shouldn't be applied to other places where the return value of the select method is used, and process the selectedKeys regardless of the return value.
—
Reply to this email directly or view it on GitHub.
Merged in the workaround for epoll bug. @kimchy could you please retest with latest code out of the 3 branch and see if you can still get into 100% cpu usage ?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/535#issuecomment-8137935.
Activity
kimchy commentedon Aug 22, 2012
more info:
It seems like its getting into a spin in this case, where it always keeps on retrying. This might happen because of an Unexpected exception in the selector loop happening with a CancelledKeyException (still trying to track this one down), sadly don't have the stack trace for it.
Note, I don't believe that this happens only on close of the boss, as I have seen users reporting the CancelledKeyException even when no bootstrap is actually being closed.
Here is the CancelledKeyException stack trace (note, netty is embedded):
@normanmaurer / @trustin, what do you think?
kimchy commentedon Aug 22, 2012
One more note on the
java.nio.channels.CancelledKeyException, it happens when the bootstrap is not closed as well.Add a workaround for the 100% cpu usage that can happen because of an…
normanmaurer commentedon Aug 23, 2012
@kimchy could you please checkout the nio_100percent_cpu_fix branch, build a snapshot and test with it ? I think this should fix it
kimchy commentedon Aug 23, 2012
@normanmaurer will do today, it took me a couple of days to get to when it happens..., so hard to say when it stops happening, but, looking at your fix, it looks good!
Move the catch block out of the connect method, which makes more sens…
normanmaurer commentedon Aug 23, 2012
@kimchy just did some minor cleanup/change to make it "more compact". So please use this one... I'm awaiting your feedback! And thanks again for reporting!
kimchy commentedon Aug 23, 2012
@normanmaurer the fix is great, I suggest we push it, its important. I did though get into the same test once (sadly) with 100% CPU as described in the initial issue description, not much more info yet. I am still trying to figure out if its related to trying to release the bootstrap with concurrency problems around trying to open a connection at the same time, or its not really related to releasing a bootstrap, and its simply in a shutdown state because the test released it. Maybe @trustin can chip in...
kimchy commentedon Aug 23, 2012
@normanmaurer I am going to play a bit in my usecase, and make sure that no client connection might be initiated while shutting down the client bootstrap, will see if it helps, but +1 on pushing your fix for now.
normanmaurer commentedon Aug 24, 2012
So you thing the commit fix only part of the problem, right?
Sent from my iPhone. Excuse any typos....
Am 24.08.2012 um 01:21 schrieb Shay Banon [email protected]:
kimchy commentedon Aug 24, 2012
@normanmaurer yes, I don't think its a full fix...
normanmaurer commentedon Aug 24, 2012
A stacktrace and a thread-dump could help me to solve it completly. Or even
better a yourkit dump ;)
2012/8/24 Shay Banon [email protected]
kimchy commentedon Aug 24, 2012
Not sure if that will help, what happens is that you get into a spin in the client Boos thread with all the mentioned state explained in the issue dec (current keys, and so on). A thread dump will just show that its in the middle of doing something in the client boss thread.
Merge pull request #555 from netty/nio_100percent_cpu_fix
1 remaining item
normanmaurer commentedon Aug 24, 2012
@kimchy could you please tell me what java version you are using and what os ? I have a suspect, and if I'm right then its a jdk bug !
Don't rely on the return value fo Selector.select(..) as it is buggy …
normanmaurer commentedon Aug 24, 2012
@kimchy please test with latest code out of the jdk_bug_workaround branch. I think that should be it.
https://github.com/netty/netty/tree/jdk_bug_workaround
:)
kimchy commentedon Aug 24, 2012
@normanmaurer I was suspecting that, but I never managed to prove that this was the problem, since once I managed to recreate it, the select returns 0, but the seclectKeys was empty, though, I suspect, the weird combination of select return 0 yet having selectedKeys might be applied only for the first iteration and then we get into the constant state described above.
normanmaurer commentedon Aug 24, 2012
I was able to at least see this one time.. So I think this should fix it. Let me know if you still manage to get into 100%cpu usage.
Sent from my iPhone. Excuse any typos....
Am 24.08.2012 um 19:08 schrieb Shay Banon [email protected]:
kimchy commentedon Aug 24, 2012
Great that you were able to repro it!, it takes me some time to get to a state where it happens. Wondering, with the change you made, if it shouldn't be applied to other places where the return value of the select method is used, and process the selectedKeys regardless of the return value.
normanmaurer commentedon Aug 25, 2012
Yeah will check.. Just wanted to see first if it fix it for you.
Sent from my iPhone. Excuse any typos....
Am 24.08.2012 um 22:11 schrieb Shay Banon [email protected]:
normanmaurer commentedon Aug 25, 2012
@kimchy @trustin I think this 100% cpu usage could also be created because of an epoll(..) bug.
See #565
Merge workaround for epoll(..) bug into master branch. See #365 , #535 …
normanmaurer commentedon Aug 29, 2012
Merged in the workaround for epoll bug. @kimchy could you please retest with latest code out of the 3 branch and see if you can still get into 100% cpu usage ?
Fix checkstyle. See #535
kimchy commentedon Aug 29, 2012
Quick look at current 3 brach, this: https://github.com/netty/netty/blob/3/src/main/java/org/jboss/netty/channel/socket/nio/SelectorUtil.java#L61, should be toNanos, not toMicros.
normanmaurer commentedon Aug 30, 2012
Fixed.. Thanks for review again
2012/8/29 Shay Banon [email protected]
Ensure memory is released even when we cant allocate a CRYPTO_BUFFER (n…