[
https://jira.jboss.org/browse/JBSEAM-4669?page=com.atlassian.jira.plugin....
]
Denis Forveille commented on JBSEAM-4669:
-----------------------------------------
Here is the deadlock scenario, involving two threads : T1 and T2. All the components are
of "application" scope:
The scenario could have been much simpler I guess, but this is the one that corresponds to
the attached partial thread dump taken for our prod
In the attached file, T1 is the thread named "WebContainer : 22" and T2 is
"WebContainer : 8"
T1: an xhtml page references a component created from a method annotated with @Factory
T1:
T1: Seam detects that the component is a "factory component" and identifies the
component that holds the method that will create this factory component (let's call it
the "factory holding component:" FHC
T1: it then goes through the Component.getInstanceFromFactory method and takes a lock
T1: before calling the method that will create the factory, Seam starts to perform
injections for FHC (thanks to BijectionInterceptor)
T1: one of the component injected in FHC is a component created from a method annotated
with @Unwrap (let's call it the "unwrap component" : UC) declared in another
class (let's name it the "unwrap holdind class": UHC)
T2: another xhtml page action calls a method in a totally different component (TDC). This
component has to be injected the same component as in thread 1: UC (created from a method
annotated with @Unwrap)
T2: Seam identifies the class and method that will create the Unwrap component and starts
to perform injections for the class that holds the Unwrap method (component UC in class
UHC) before calling the method
T2: the BijectionInterceptor instance of UC takes a reentrant lock (BijectionInterceptor
line 48)
T2: BI-UC starts the injection of components in the classes thats holds @Unwrap component
(BijectionInterceptor line 61)
T2: Seam injects all the kind of things that can be injected including parameters even if
they are no such things in the involved classes (Component line 1547 then 1556 and 1581)
T2: For this, Seam calls Component.getInstance to get the
"org.jboss.seam.web.parameters" component (Parameters line 81) that will later
call Component.getInstanceFromFactory
T2: Unfortunately Component.getInstanceFromFactory is locked by Thread 1......
T1: before calling the @Unwrap method, the BijectionInterceptor (BI) associated with UC
detects that UH needs to have another component injected
T1: the instance of BI of UC (tries to) take a reentrant lock (BI line 44) but can't
as it is held by Thread 2, and it starts to wait (LockSupport.park) ...
Seems complex but it is very simple in fact
The synopsis of the classes is :
Class FHC:
----------------
@Name("FHC")
...
@In
UC uc;
...
@Factory(name="something") <--- referenced in xhtml page by T1
public whatever theMethodToCreateTheFactoryComponentReferencedInXHtml(){
...
}
Class TDC:
----------------
@Name("TDC")
...
@In
UC uc;
public void anActionMethodCalledFromAnotherXHtmlPage() { <-- intial call of T2
...
}
Class UHC:
----------------
@Name("UC)
..
@In
private AnotherComponent anotherComponent;
...
@Unwrap
public whatever createFactory() {
...
}
Major java deadlock between BijectionInterceptor and Component since
the getInstanceFromFactory method is synchronized
-----------------------------------------------------------------------------------------------------------------------
Key: JBSEAM-4669
URL:
https://jira.jboss.org/browse/JBSEAM-4669
Project: Seam
Issue Type: Bug
Components: Core
Affects Versions: 2.2.1.CR2
Reporter: Denis Forveille
Assignee: Denis Forveille
Priority: Blocker
Fix For: 2.2.1.CR2
Attachments: ManagerComponentTest.java
To address JBSEAM-2419, the Component.getInstanceFromFactory(String name) is now
"synchronized"
This causes java deadlocks under stress with the call to lock.lock() in
BinjectionInterceptor ...
For us our apps freezes after 10 minutes in production,,,
I don't know why this method has been marked as synchronized but this is the cause of
the deadlock...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira