[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-3652) Major reentrancy problem with "Page Scope" components and injection/disinjection

Dan Allen (JIRA) jira-events at lists.jboss.org
Fri Nov 14 16:25:36 EST 2008


    [ https://jira.jboss.org/jira/browse/JBSEAM-3652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12438544#action_12438544 ] 

Dan Allen commented on JBSEAM-3652:
-----------------------------------

I'll start with the easy question. Yes, in 2.1.1 I added @Synchronized to page-scoped components. However, if there is a chance that the user really will double submit the form, and you want both calls to succeed, I would suggest adding @Synchronized because the default timeout is pretty short and will likely cause one of the calls to timeout (resulting in an error page).

Okay, back to case #2. This is one of those points where it is hard to find the right words to explain what is going on, but I will keep trying. First, @Create methods *are* synchronized by Seam, just like any other business method on a @Synchronized component. What you are observing is something entirely different. As far as Seam is concerned, the page scope remains untouched until the end of the request. Thus, if you submit a UI command button N times in parallel, then there is no communication between those N thread-local page scopes (in terms of the addition of new variables). Thus, all N requests think they need to instantiate the page-scoped component and therefore you get N instances. That means N calls to a @Create method, but each call happens on a different instance (this is not a synchronization problem in that regard). At the beginning and end of the render phase, the thread-local page scope is flushed to the UI component tree. At that point, the last request wins and overwrites the instances created by the other N - 1 requests.

What we would need to avoid this situation is for access to the UI component tree to be synchronized, in the same way that access to the conversation is synchronized. It cannot be solved at the component level.

BTW,  the buffered page context variables are placed into the faces view root at the beginning of the render phase.

> Major reentrancy problem with "Page Scope" components and injection/disinjection
> --------------------------------------------------------------------------------
>
>                 Key: JBSEAM-3652
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3652
>             Project: Seam
>          Issue Type: Bug
>    Affects Versions: 2.0.2.SP1, 2.0.3.CR1, 2.1.0.GA
>         Environment: WebSphere v6.1.0.17 in POJO Mode 
>            Reporter: Denis Forveille
>            Assignee: Dan Allen
>            Priority: Blocker
>             Fix For: 2.1.1.CR1
>
>         Attachments: Test3652.java, Test3652Conv.java, testJBSEAM3652.xhtml, traces.txt
>
>
> This bug is very similar to the JBSEAM-3295 bug, but for "Page Scope" components this time
> Under stress, we have random NPE, "conversation expired" and other strange eroors from time to time in production
> This is due to a flaw in the "BijectionInterceptor" class and it is quite easy to reproduce
> On a facelets page, we have a datatable with a list of h:commadLink, teh first page of a classic "list entities/showDetail" scheme. The controleur that manages the list is in "Page Scope"
> When the user clics on one of the link, then quickly clic on another link, another one etc...  without waiting for the detail view to show up, we have two concurrent request addressed to the same Page Scope component (Verified by putting traces in the BijectionInterceptor class)
> In BijectionInterceptor, in that case, counter == 2 after line 77  meaning there is two concurrent thread running: the current thread + another one currently "using" the component
> The counter will be decrease for the first time on line 82,  then a second time on line 129 and so, disinjection will occur on line 134. This occurs while there is another thread "using" the component, causing random NPE and other errors!!!!
> In fact this will happen each time counter >1, ie there is more than one "concurrent" request on the same component
> This alleviate some questions:- 
> - is this normal that 2 (or more) concurrent request from the same user/conversation/page acces the same page scope component concurrently (I thought seam was taking care of this and was serializing such requests...
> - is this normal that on line 88, components are outjected, only when the last concurrent "user" of the component exits the interceptor and not when each request "eixts" the interceptor?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the seam-issues mailing list