jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@day.com>
Subject Re: deadlock problem
Date Mon, 28 Nov 2005 10:04:44 GMT
Brian Moseley wrote:
> Marcel Reutegger wrote:
> 
>> what revision of jackrabbit are you using? according to the line 
>> numbers in the thread dumps at least the SharedItemStateManager is not 
>> up to date.
>>
>> there was an issue with locking some time ago.
>> http://issues.apache.org/jira/browse/JCR-194
>>
>> is that fix included in your build?
> 
> 
> i remember that issue. it was fixed in r239410, according to jira. im 
> running r330363, tho :/

hmm, I had another look at the thread dumps and the problem is indeed 
the ReentrantWriterPreferenceReadWriteLock as you indicated in your 
first post.

3 threads need to be involved for the deadlock:

thread-1: stores modification and is notifying events listeners (SISM 
holds read lock), one of the listener is the lock manager (lock manager 
is held by thread-2)

thread-2: checks locks state of a node (holds lock manager), lock 
manager attempts to acquire a read lock on the SISM. there is a request 
for a write lock by thread-3 which has preference.

thread-3: attempts to store modification, wants to acquire a write lock 
on the SISM. waits for thread-1.

and the circle is closed :-/


changing the preference to readers will solve this issue. but I'm not 
sure if there will be side effects with this change.

I'll run some tests first before I commit the change.

He is my suggested change:


Index: SharedItemStateManager.java
===================================================================
--- SharedItemStateManager.java	(revision 349402)
+++ SharedItemStateManager.java	(working copy)
@@ -144,7 +144,14 @@
       * Read-/Write-Lock to synchronize access on this item state manager.
       */
      private final ReadWriteLock rwLock =
-            new ReentrantWriterPreferenceReadWriteLock();
+            new ReentrantWriterPreferenceReadWriteLock() {
+                /**
+                 * Use reader preference policy.
+                 */
+                protected boolean allowReader() {
+                    return true;
+                }
+            };

      /**
       * Creates a new <code>SharedItemStateManager</code> instance.



regards
  marcel

-- 
-----------------------------------------< marcel.reutegger@day.com >---
Marcel Reutegger, Day Software AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Mime
View raw message