Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Selector.select() returned prematurely 512 times in a row; rebuilding selector while run testsuite #2616
Comments
normanmaurer
added this to the 4.0.21.Final milestone
Jun 27, 2014
|
After more debugging this only happens on linux kernel 3.14. After downgrade to kernel 3.10.45 all works like expected. The problem can be reproduced with pure java.nio: import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
public class SelectorBug {
public static void main(String[] args) throws Exception {
SelectorLoop selectThread = new SelectorLoop();
selectThread.start();
SocketChannel channel = SocketChannel.open();
channel.configureBlocking(false);
SelectionKey key = channel.register(selectThread.selector, 0, null);
selectThread.selector.wakeup();
Thread.sleep(10000);
selectThread.shutdown();
key.cancel();
}
private static final class SelectorLoop extends Thread {
private volatile boolean shutdown;
private final Selector selector;
SelectorLoop() throws IOException {
selector = Selector.open();
setDaemon(true);
}
@Override
public void run() {
while (!shutdown) {
try {
long before = System.nanoTime();
int selected = selector.select(1000);
System.out.println("Selected=" + selected + ' ' + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - before));
if (selected > 0) {
Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
while (keys.hasNext()) {
keys.next();
keys.remove();
}
}
} catch (IOException e) {
e.printStackTrace();
break;
}
}
try {
selector.close();
} catch (IOException e) {
// ignore
}
}
public void shutdown() {
shutdown = true;
}
}
}Normally you should not see more then about 11 print statements. With kernel 3.14 I see thousands. |
|
Linux Kernel 3.15:
|
normanmaurer
modified the milestones:
4.0.22.Final,
4.0.21.Final
Jul 1, 2014
|
Also fixed in latest 3.14.10 kernel:
|
normanmaurer
closed this
Jul 1, 2014
trustin
added
the
defect
label
Aug 14, 2014
normanmaurer
self-assigned this
Aug 14, 2014
trustin
added
not a bug
and removed
defect
labels
Aug 14, 2014
trustin
removed this from the 4.0.22.Final milestone
Aug 14, 2014
kdubb
referenced this issue
in impossibl/pgjdbc-ng
Jul 23, 2015
Closed
Selector.select() returned prematurely 512 times in a row; rebuilding selector #191
PatrickHuetter
commented
Dec 10, 2015
|
I've the same problem with linux kernel 4.2 and 3.16. (Debian Jessie) |
adleong
referenced this issue
in linkerd/linkerd
Sep 12, 2017
Closed
High CPU load and many netty errors for Namerd 1.1.3 #1627
|
Also seeing this with a custom kernel 4.13.3 on Gentoo. Any idea if this is a kernel configuration issue, not a kernel bug? |
|
@timboudreau sorry no idea :( |
yarondav
commented
Nov 22, 2017
|
We're seeing this as well on our Play! app. Netty 4.0.51.Final java version "1.8.0_121" uname -r : 4.9.20-11.31.amzn1.x86_64 Happens under heavy load. Any help would be appreciated. |
normanmaurer commentedJun 27, 2014
The following is logged on my crunchbang linux installation:
This is reproducible all the time