Hi,
1) Scheduler thread cost much CPU, I enabled monitor module, there're stack traces of busy threads:
16:07:42.560:WARN:oejm.ThreadMonitor:Thread-13:
org.eclipse.jetty.monitor.thread.ThreadMonitorException: Thread 'Scheduler-225690927'[RUNNABLE,id:34,cpu:92.65%] STACK TRACE
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:225)
at sun.nio.ch.IOUtil.read(IOUtil.java:198)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:375)
at org.eclipse.jetty.io.ChannelEndPoint.fill(ChannelEndPoint.java:136)
at org.eclipse.jetty.server.HttpInputOverHTTP.nextContent(HttpInputOverHTTP.java:104)
at org.eclipse.jetty.server.HttpInputOverHTTP.nextContent(HttpInputOverHTTP.java:30)
at org.eclipse.jetty.server.HttpInput.getNextContent(HttpInput.java:110)
at org.eclipse.jetty.server.HttpInput.consumeAll(HttpInput.java:245)
at org.eclipse.jetty.server.HttpConnection.completed(HttpConnection.java:327)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:401)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:238)
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1159)
at org.eclipse.jetty.server.HttpChannelState.complete(HttpChannelState.java:440)
at org.eclipse.jetty.server.AsyncContextState.complete(AsyncContextState.java:92)
at my.web.async.BasicAsyncListener.onTimeout(BasicAsyncListener.java:34)
at org.eclipse.jetty.server.HttpChannelState.expired(HttpChannelState.java:396)
at org.eclipse.jetty.server.HttpChannelState$AsyncTimeout.run(HttpChannelState.java:699)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
16:18:18.738:WARN:oejm.ThreadMonitor:Thread-13:
org.eclipse.jetty.monitor.thread.ThreadMonitorException: Thread 'Scheduler-225690927'[RUNNABLE,id:34,cpu:92.94%] STACK TRACE
at sun.nio.ch.NativeThread.current(Native Method)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:321)
at org.eclipse.jetty.io.ChannelEndPoint.fill(ChannelEndPoint.java:136)
at org.eclipse.jetty.server.HttpInputOverHTTP.nextContent(HttpInputOverHTTP.java:104)
at org.eclipse.jetty.server.HttpInputOverHTTP.nextContent(HttpInputOverHTTP.java:30)
at org.eclipse.jetty.server.HttpInput.getNextContent(HttpInput.java:110)
at org.eclipse.jetty.server.HttpInput.consumeAll(HttpInput.java:245)
at org.eclipse.jetty.server.HttpConnection.completed(HttpConnection.java:327)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:401)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:238)
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1159)
at org.eclipse.jetty.server.HttpChannelState.complete(HttpChannelState.java:440)
at org.eclipse.jetty.server.AsyncContextState.complete(AsyncContextState.java:92)
at my.web.async.BasicAsyncListener.onTimeout(BasicAsyncListener.java:34)
at org.eclipse.jetty.server.HttpChannelState.expired(HttpChannelState.java:396)
at org.eclipse.jetty.server.HttpChannelState$AsyncTimeout.run(HttpChannelState.java:699)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
2) There's no blockForContent() in stack trace this time. I've found blockForContent() before I set a customized ReadListener.
3) I did a test later to verify whether jetty hold correct state or not. I changed org.eclipse.jetty.server.HttpConnection.completed method, line 325-327:
else if (_parser.inContentState() && _generator.isPersistent()) {
LOG.warn(String.format("req=%s, _parser=%s, _parser.eof=%s", _channel.getRequest(), _parser, _parser.isAtEOF()), new Exception("testparserstate")); // Complete reading the request
_channel.getRequest().getHttpInput().consumeAll(); }
and also my.web.async.BasicAsyncListener.onTimeout
public void onTimeout(AsyncEvent event) throws IOException {
logger.debug("onTimeout> req={}, params={}", asyncCtx.getRequest(), (reqInfoHolder != null ? reqInfoHolder.getParameterMap() : null));
reqInfoHolder will be initialized in myReadListener.onAllDataRead().