jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@gmail.com>
Subject Re: [jr3] Synchronized sessions
Date Fri, 26 Feb 2010 17:36:06 GMT

On 25.02.2010 16:33, Thomas Müller wrote:
>> this creates a big potential for deadlocks
> Could you provide an example on how such a deadlock could look like?

While I could not yet come up with such an example, I found another
problem involving data inconsistency.

Consider two threads T1 and T2 each modifying data from the same session:

  T1 makes some modifications
  T2 makes some modifications
  T1 saves the session (incl. both T1's and T2's modifs)
  T2 makes some more modifications
  T2 decides to rollback

At the end the content is inconsistent from the POV of T2 because some
modifications have been persistent and some haven't.

Thus, method synchronization gives a false impression of thread safety.


>> just synchronizing all methods
>> So you also synchronize all Node/Item/Property methods
> Some methods don't need to be synchronized, for example some getter
> methods such as Session.getRepository(), RangeIterator.getPosition()
> and getSize(). I'm not sure if Node.getProperty needs to be
> synchronized. The Value class is (almost) immutable so synchronization
> is not required here. But very likely Session.getNode(..) and
> Node.getNode() need to be synchronized because those potentially
> modify the cache.
>> ensure that for a given Item x, the same Item instance is always returned from all
getXXX methods ....
> I'm not sure what you are referring to. Jackrabbit already does ensure
> the same node object is returned as far as I know, but for other
> reasons than synchronization.
>> if people do the wrong things, well, fine, let them do ...
> It's usually not those people that have to fix broken repositories.
>> my veto
> Let's see.
>> Most jcr apps I've seen often use a single session from several threads to read from
this session. (I think I also read it somewhere that this is safe with jackrabbit, but I might
be mistaken).
> I'm not sure if this is really safe. Maybe it is problematic if one
> thread uses the same session for updates.
>> Simply syncing everything on the session would decrease performance in these cases
> Actually, I don't think that's the case.
> Regards,
> Thomas

View raw message