jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig <mdue...@apache.org>
Subject Re: Session concurrency warning
Date Thu, 10 Apr 2014 08:44:50 GMT


On 10.4.14 2:24 , Alexander Klimetschek wrote:
> On 09.04.2014, at 07:15, Michael Dürig <mduerig@apache.org> wrote:
>
>> On 9.4.14 4:12 , Rob Ryan wrote:
>>> It would be appropriate to change the warning to warn about
>>> concurrent reads as well. That would help highlight performance
>>> risks.
>>
>> There is such a warning actually. The discussion here was about the
>> incorrect warning that is issued when writing concurrently.
>
> So when 2 threads use the same session for read operations, then you
> get another warning ("concurrent access")?

Right but only at debug level.

>
> If the threads are synchronized, so one finishes its session
> operations, then the other thread uses it (not in parallel), and when
> that other thread has finished, the first one again reads from the
> session, would you get a warning then? AFAIC, the messages are
> triggered only when it has to wait for another thread.

Exactly. Each operation tries to acquire a lock and logs a warning if it 
fails before eventually blocking on that lock:

if (!lock.tryLock()) {
   // log concurrent access
   lock.lock();
}
try {
   // repository operation
} finally {
   lock.unlock();
}

See 
https://github.com/apache/jackrabbit-oak/blob/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java#L264

Michael


>
> I know, concurrent use of sessions must be avoided. I am just curious
> to fully understand the issue I am seeing.
>
> Cheers, Alex
>

Mime
View raw message