> I've been investigating a broader approach that identifies when > multiple threads are operating on the same session and serializes > those requests using a per-session lock (possibly, by synchronizing on > the session relatively early in the pipeline)
There are times when you want your session to be accessed in parallel. For instance, consider a private image gallery where image requests are protected using information stored in the session. This is the use-case that pointed out the problem with forcing cluster updates by setting the session attributes to null briefly (causing a new session attribute created). Forcing a multi-threaded app to run serially seems a little drastic. Josh On Mon, May 16, 2011 at 5:41 PM, Howard Lewis Ship <[email protected]> wrote: > That's a very good catch; it's difficult to do work that requires > synchronizing the Session because locking it can also cause deadlocks. > I've been investigating a broader approach that identifies when > multiple threads are operating on the same session and serializes > those requests using a per-session lock (possibly, by synchronizing on > the session relatively early in the pipeline). > > On Mon, May 16, 2011 at 12:31 PM, David Rees <[email protected]> wrote: >> On Mon, May 16, 2011 at 7:57 AM, antalk <[email protected]> wrote: >>> Thanks for your message, i hope it is now clear that it indeed is a issue >>> somewhere within Tapestry. As a matter of fact i didn't saw this message for >>> a long time on our test machines. But just today i encountered the same >>> issue again. >> >> It looks like SessionImpl.getAttributeNames should be reworked to >> synchronize on the session - or at least catch the >> ConcurrentModificationException and try again (see patch below) which >> is simpler. >> >> But I worry that the same error could be thrown in the >> getAttributeNames function on line 61, too - similar technique should >> probably be used there as well. >> >> --- SessionImpl.java~ 2011-05-16 12:19:31.159348203 -0700 >> +++ SessionImpl.java 2011-05-16 12:28:35.073307235 -0700 >> @@ -72,8 +72,27 @@ >> >> public List<String> getAttributeNames(String prefix) >> { >> - List<String> result = CollectionFactory.newList(); >> + List<String> result = null; >> >> + do >> + { >> + try >> + { >> + result = getAttributeNamesFromSession(prefix); >> + } >> + catch (ConcurrentModificationException) >> + { >> + // Ignore - result will be null so we will try again >> + } >> + } >> + while (result == null); >> + >> + return result; >> + } >> + >> + private List<String> getAttributeNamesFromSession(String prefix) >> throws ConcurrentModificationException >> + { >> + List<String> result = CollectionFactory.newList(); >> Enumeration e = session.getAttributeNames(); >> while (e.hasMoreElements()) >> { >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > > -- > Howard M. Lewis Ship > > Creator of Apache Tapestry > > The source for Tapestry training, mentoring and support. Contact me to > learn how I can get you up and productive in Tapestry fast! > > (971) 678-5210 > http://howardlewisship.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
