JBoss deadlocks and hangs accessing synchronized Seam components
Environment
- JBoss Enterprise Application Platform (EAP)
- Seam
Issue
- JBoss hangs due to threads that are deadlocked on synchronized Seam components, like so:
"ajp-0.0.0.0-8009-1" daemon prio=10 tid=0x000000004b8c4800 nid=0x350c waiting on condition [0x0000000061778000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x0000000774430a88> (a java.util.concurrent.locks.ReentrantLock$FairSync) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198) at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireNanos(AbstractQueuedSynchronizer.java:905) at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireNanos(AbstractQueuedSynchronizer.java:1224) at java.util.concurrent.locks.ReentrantLock.tryLock(ReentrantLock.java:416) at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:28) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
Resolution
- Ensure the Seam components' synchronized timeouts are not set too high. Usually something around 1 to 5 seconds suffices:
@Synchronized(timeout=5000)
Root Cause
- Multiple threads hit the same Seam components at once to cause a deadlock.
- These components should have a synchronized timeout, meaning this deadlocked state couldn't last any longer than the timeout.
- If this timeout is set very high, this deadlock can persist for quite some time to back up many threads.
Diagnostic Steps
- Troubleshoot using thread dumps and additional steps mentioned in Java application unresponsive.
Components
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.