Bug 42925

Summary: Sendfile thread uses 100% cpu for long periods
Product: Tomcat 6 Reporter: Chris Lear <chris.lear>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: major CC: celving, clovis.wichoski, muralie.vr
Priority: P2    
Version: unspecified   
Target Milestone: default   
Hardware: PC   
OS: Linux   
Attachments: Proposed patch

Description Chris Lear 2007-07-18 01:53:44 UTC
Tomcat 6.13 using APR, running under jsvc on linux (debian, but tomcat isn't
installed via apt-get) 2.6.21 SMP. Sun Java 1.6.0.

After tomcat was running for a short while (<15mins), cpu usage on one cpu would
go to 100%, as shown by top. Using ps xU tomcat -fL showed that one tomcat
thread was using far more cpu than all the others. Cross-referencing the thread
id to a thread dump (from kill -3) showed that it was the sendfile thread that
was consuming all the cpu time.

Tomcat was still responding to requests while this was going on, but obviously
the high cpu load was not necessary or helpful. Watching cpu usage via top
showed that at times it would return to normal, but never for long.

Workaround: I added 'useSendfile="false"' to the http connector, restarted
tomcat, and it has now run with normal cpu usage for over 12 hours.
Comment 1 Chris Elving 2007-09-25 19:44:40 UTC
This is a result of AprEndpoint.Sendfile.init calling Poll.create with a timeout
parameter but never calling Poll.maintain to deal with the resulting poll
descriptor timeouts. My work around was to pass a timeout of -1 to Poll.create.
Comment 2 Remy Maucherat 2007-10-05 14:01:58 UTC
Created attachment 20930 [details]
Proposed patch

This patch replaces the TODO with code that calls maintain. I was not aware
calling maintain was more or less mandatory.
Comment 3 Mark Thomas 2007-11-29 15:12:25 UTC
This was fixed in rev 583650.
Comment 4 Mark Thomas 2008-05-07 00:16:47 UTC
*** Bug 44938 has been marked as a duplicate of this bug. ***