Mantis - Resin
Viewing Issue Advanced Details
5861 major always 03-03-15 19:04 03-30-15 10:39
cyflhn  
ferg  
normal  
closed 3.1.13  
no change required  
none    
none 3.1.14  
0005861: thread pool dead loop
Thread pool dead loop often occurs especially when writing access log and the value of thread-max is not configured very high. I have checked the code. In ThreadPool.java, in method of schedule (line 481), if "poolItem"!=null and freeThreads >= freeCount, the "poolItem" will not be removed from link list headed by "_idleHead".But in line 547, method "start" of "poolItem" is invoked.So "poolItem" will become active. When "poolItem" becomes idle and returns to link list(line 702), if currently "_idleHead" points to "poolItem" itself, then _idleHead._next will point to itself. When the method "schedule" is invoked again, maybe the "poolItem" which is the current "_idleHead" is removed from link list and the poolItem._next is null(line 490). so "_idleHead" will be null forever if no other poolItems is returned to link list. Writing access log is invoked by startPriority(line 414). One thread which can not get a poolItem will block all other threads when writing access log. There is similar case in 0003509, but the problem still exists in 3.1.13.
Enviroment:
Linux/Sun JDK 1.7.55/Resin 3.1.13 Open source
Max Thread count: 256
about 10M visit one day
2cpu 4G memory
 6988_1 [^] (26,233 bytes) 03-03-15 19:04

Notes
(0006597)
ferg   
03-30-15 10:39   
Resin 3.1 is frozen.

Note, the max thread for a 64-bit system should be expanded to something much larger, like 4096, which will avoid the problem.

The old default of 256 was small because at the time of Resin 3.1's release, 32 bit machines were more common and large numbers of threads were not well supported by the operating system.