History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: UP-1816
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Eric Dalquist
Reporter: Elliot Metsger
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
uPortal

Objects attached to a PortletSession randomly disappear

Created: 05/Sep/07 11:12 PM   Updated: 02/Oct/07 01:05 PM
Component/s: Portlet Container
Affects Version/s: 2.5.2 GA, 2.5.3 GA, 2.6.0 GA
Fix Version/s: 2.5.4

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Text File reserves-numbered.log (7 kb)
2. File threadedPortletRendering_25.diff (34 kb)
3. File threadedPortletRendering_26.diff (34 kb)

Environment:
Observed on:
uPortal 2.5.3/Tomcat 5.5.23/Pluto 1.0.1-rc2 - Guelph
uPortal 2.5.2/Tomcat 5.5.23/Pluto 1.0.1-rc3,1.0.1-ga - JHU
uPortal 2.5.3/Tomcat 5.5.20/Pluto 1.0.1-rc2 - University of the West of England
uPortal 2.6.0/Tomcat 5.5.23/pluto-1.0.1.jar - Southern Utah University
uPortal 2.6.x patches branch (r42431)/Tomcat 5.5.23/Pluto 1.0.1 - JHU

Not Observed on:
uPortal 2.5.2(modified)/Tomcat 5.5.20/Pluto 1.0.1-ga - UW


 Description  « Hide
Attributes set on a PortletSession object seem to be randomly lost on subsequent requests.

E.g. on one request:

PortletSession session = request.getPortletSession();
session.setAttribute( "foo", new Object() );

On subsequent requests:

PortletSession session = request.getPortletSession();
Object foo = session.getAttribute( "foo" );

Object foo is randomly null.

This experience is documented in various email threads:

http://www.nabble.com/uPortal-Session-Failures--tf4116258.html
http://www.nabble.com/forum/ViewPost.jtp?post=12099547&framed=y

 All   Comments   Work Log   Change History   FishEye      Sort Order:
Elliot Metsger [05/Sep/07 11:13 PM]
The affected versions are set according to what users have reported on the list.

Elliot Metsger [06/Sep/07 12:46 AM]
Attaching debug level output (reserves-numbered.log) from a JHU portlet exemplifying the issue. The output was captured by rendering the portlet 4 times. The first time the portlet is rendered, objects are initialized and placed into the session. On the three subsequent requests, the objects are retrieved from the session.

It appears that the PortletContext referenced by the PortletSession is improperly managed. If the PortletContext is improperly managed, then it may indicate a broader issue.

Lines 1 and 2 set two objects into the session on request number 1.

Line 6 prints out the session on request number 2. Note that the objects set on the first request are still present.

Line 13 prints out the session on request number 3. Same objects still present.

Line 20 prints out the session on request number 4. Objects are missing. Same session id. Different portlet context name.


Elliot Metsger [10/Sep/07 02:08 AM]
What follows is a high level description of what I think the issue is... the details are gory.

CPortletAdapter is accessed by multiple threads simultaneously attempting to render the same http request object. Ultimately CPortletAdapter calls the Pluto container to render the request, which is performed using cross-context dispatch.

When Tomcat is performing request dispatching, it unwraps the request down to the first Tomcat-specific concrete request object it finds, wraps that with a Tomcat ApplicationHttpRequest, then performs the dispatch.

If thread X is dispatching request A, Tomcat will insert an ApplicationHttpRequest wrapper in the wrapping chain.

Thread Y is simultaneously dispatching request A, and so Tomcat will insert an additional ApplicationHttpRequest wrapper into the wrapping chain.

This leads to a condition where different threads may observe the request with only a single ApplicationHttpRequest wrapper or - after it has been wrapped a second time - with two ApplicationHttpRequest wrappers.

The ApplicationHttpRequest wrapper (at least in Tomcat 5.5.23) is responsible for managing the SessionFacade which is returned to callers of getPortletSession(). A request wrapped with only one ApplicationHttpRequest returns a different SessionFacade than the request wrapped with two ApplicationHttpRequest objects.

So it is possible for a Pluto PortletRequest to obtain the correct SessionFacade (the SessionFacade is what backs the Pluto PortletSession) on one request, but it may obtain a different SessionFacade on subsequent requests, if the request is affected by this race condition and has been doubly-wrapped with the ApplicationHttpRequest.


Elliot Metsger [10/Sep/07 11:55 PM]
I can confirm that on a build of r4249 of the https://developer.ja-sig.org/svn/up2/branches/rel-2-6-patches branch - HEAD at the time of this comment - that this bug exists on Tomcat 5.5.23, Pluto 1.0.1.

Time for more debugging....


Elliot Metsger [10/Sep/07 11:57 PM]

Elliot Metsger [12/Sep/07 01:15 PM]
Eric Dalquist at the University of Wisconsin has offered to supply a patch that we think addresses this issue. Eric has (thank you thank you) offered to patch both the 2.5 and 2.6 patches branch.

After the patch has been committed, JHU will be testing the patch, and I'll email the uportal users list and ask the other affected schools to test as well.


Elliot Metsger [12/Sep/07 01:18 PM]
Chat transcripts from the past few days may be instructional, here is a link to the transcript for 9/11: http://www.ja-sig.org/wiki/x/LANz

Transcripts from earlier days also have discussion about this issue.


Eric Dalquist [12/Sep/07 03:53 PM]
Possible fix for session issue. Involves adding a custom wrapper than tomcat can't un-wrap to each request before it is rendered and adding ThreadLocals for tracking render parameters and request/response objects.

The patch was generated against the 2.5-patches branch rev 42374


Eric Dalquist [12/Sep/07 04:59 PM]
2.5-patches diff

Eric Dalquist [12/Sep/07 04:59 PM]
2.6-patches diff

Elliot Metsger [12/Sep/07 05:49 PM]
JHU has tested the 2.6 patch on HEAD of the rel-2-6-patches branch with Pluto 1.0.1 and Tomcat 5.5.23 and Spring 2.0.6. It seems to fix the issue for us! I'll be testing the 2.5 patch shortly.

Christopher J. Holdorph [18/Sep/07 12:12 PM]
I had to patch part of it by hand, but after that I was able to 'make my problem not appear'. Hard to prove it's gone completely, because it was never completely deterministic, but since applying the patch I haven't seen the problem again.

uPortal 2.6.0GA + patch, Tomcat 5.5.23, HSQLDB 1.8.0.7


Parker Grimes [18/Sep/07 02:26 PM]
I also had to patch part of it by hand, specifically PortalControlStructures.java. We have NOT experienced the problem since applying the patch. We were having session problems very consistently before the patch and have not had any session problems since the patch.

uPortal 2.6.1 RC1, Tomcat 5.5.23, Oracle 10g