https://issues.apache.org/bugzilla/show_bug.cgi?id=56530
Bug ID: 56530 Summary: WebappClassLoader.loadClass synchronization issue due to coarse lock at WebappClassLoader instance level instead of been by class name Product: Tomcat 7 Version: 7.0.53 Hardware: PC Status: NEW Severity: major Priority: P2 Component: Catalina Assignee: dev@tomcat.apache.org Reporter: sebtar...@ncf.ca I'm having some visible performance issue related to the use of method synchronized loadClass(String name, boolean resolve) in WebappClassLoader I see that the author or at least some of the author(s) of the class WebappClassLoader got the idea in other cases of a more specialize lock than WebappClassLoader instance. Should we just lock here using the name of the class we are looking for? Also we should probably make the distinction between read and write. The scenario here, is classic cache factory synchronization. So we could just copy the right locking pattern from other sources. My partial threads stack dump: 2014-05-14 12:36:01 Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.45-b01 mixed mode): "http-bio-31680-exec-57" - Thread t@124 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) ... "http-bio-31680-exec-56" - Thread t@123 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-55" - Thread t@122 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) Locked ownable synchronizers: - locked <444b3957> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) "http-bio-31680-exec-54" - Thread t@121 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) "http-bio-31680-exec-53" - Thread t@120 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-52" - Thread t@119 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-51" - Thread t@118 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119) "http-bio-31680-exec-50" - Thread t@117 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-49" - Thread t@116 java.lang.Thread.State: RUNNABLE at java.lang.Class.getClassLoader0(Native Method) at java.lang.Class.getClassLoader(Class.java:589) at com.sun.xml.internal.bind.v2.model.annotation.LocatableAnnotation.create(LocatableAnnotation.java:63) at com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getAllFieldAnnotations(RuntimeInlineAnnotationReader.java:60) at com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getAllFieldAnnotations(RuntimeInlineAnnotationReader.java:42) "http-bio-31680-exec-48" - Thread t@115 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:481) "http-bio-31680-exec-47" - Thread t@114 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119) "http-bio-31680-exec-46" - Thread t@113 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-45" - Thread t@112 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:47) "http-bio-31680-exec-44" - Thread t@111 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:303) "http-bio-31680-exec-43" - Thread t@110 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) "http-bio-31680-exec-42" - Thread t@109 java.lang.Thread.State: TIMED_WAITING at sun.misc.Unsafe.park(Native Method) - parking to wait for <2aa68578> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:196) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2025) at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:424) at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:86) at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:32) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:955) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:917) at java.lang.Thread.run(Thread.java:662) Locked ownable synchronizers: - None "http-bio-31680-exec-40" - Thread t@107 java.lang.Thread.State: TIMED_WAITING at sun.misc.Unsafe.park(Native Method) - parking to wait for <2aa68578> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:196) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2025) at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:424) at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:86) at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:32) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:955) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:917) at java.lang.Thread.run(Thread.java:662) Locked ownable synchronizers: - None "http-bio-31680-exec-39" - Thread t@106 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) "http-bio-31680-exec-38" - Thread t@105 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119) at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:154) at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:241) "http-bio-31680-exec-37" - Thread t@104 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:47) at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.loadObjectFactory(ModelBuilder.java:249) "http-bio-31680-exec-36" - Thread t@103 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:303) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:289) "http-bio-31680-exec-35" - Thread t@102 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-34" - Thread t@101 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-33" - Thread t@100 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-32" - Thread t@99 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:303) "http-bio-31680-exec-31" - Thread t@98 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119) at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:154) "http-bio-31680-exec-30" - Thread t@97 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:481) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:185) "http-bio-31680-exec-29" - Thread t@96 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) "http-bio-31680-exec-28" - Thread t@95 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119) at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:154) "http-bio-31680-exec-27" - Thread t@94 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:119) "http-bio-31680-exec-26" - Thread t@93 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:505) at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:47) "http-bio-31680-exec-25" - Thread t@92 java.lang.Thread.State: BLOCKED at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1605) - waiting to lock <264d40df> (a org.apache.catalina.loader.WebappClassLoader) owned by "http-bio-31680-exec-41" t@108 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass(ObjectFactory.java:358) at com.sun.org.apache.xerces.internal.utils.ObjectFactory.newInstance(ObjectFactory.java:303) .. and more -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org