You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/02/16 12:21:37 UTC

svn commit: r744895 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Author: jukka
Date: Mon Feb 16 11:21:33 2009
New Revision: 744895

URL: http://svn.apache.org/viewvc?rev=744895&view=rev
Log:
JCR-1979: Deadlock on concurrent read & transactional write operations

Moved the virtual provider accesses outside the workspace read lock. This avoids the deadlock with a transactional write.

This change in lock scope does not endanger consistency, as all the modifiable virtual providers already have their own internal locking (as evidenced by the deadlock scenario!). In fact a global virtual provider like the version store *must* have it's own locking mechanism as it can be concurrently accessed from multiple workspaces.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=744895&r1=744894&r2=744895&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Mon Feb 16 11:21:33 2009
@@ -313,9 +313,7 @@
      */
     public NodeReferences getNodeReferences(NodeReferencesId id)
             throws NoSuchItemStateException, ItemStateException {
-
         ISMLocking.ReadLock readLock = acquireReadLock(id.getTargetId());
-
         try {
             // check persistence manager
             try {
@@ -323,18 +321,19 @@
             } catch (NoSuchItemStateException e) {
                 // ignore
             }
-            // check virtual providers
-            for (int i = 0; i < virtualProviders.length; i++) {
-                try {
-                    return virtualProviders[i].getNodeReferences(id);
-                } catch (NoSuchItemStateException e) {
-                    // ignore
-                }
-            }
         } finally {
             readLock.release();
         }
 
+        // check virtual providers
+        for (int i = 0; i < virtualProviders.length; i++) {
+            try {
+                return virtualProviders[i].getNodeReferences(id);
+            } catch (NoSuchItemStateException e) {
+                // ignore
+            }
+        }
+
         // throw
         throw new NoSuchItemStateException(id.toString());
     }
@@ -343,14 +342,12 @@
      * {@inheritDoc}
      */
     public boolean hasNodeReferences(NodeReferencesId id) {
-
         ISMLocking.ReadLock readLock;
         try {
             readLock = acquireReadLock(id.getTargetId());
         } catch (ItemStateException e) {
             return false;
         }
-
         try {
             // check persistence manager
             try {
@@ -360,15 +357,17 @@
             } catch (ItemStateException e) {
                 // ignore
             }
-            // check virtual providers
-            for (int i = 0; i < virtualProviders.length; i++) {
-                if (virtualProviders[i].hasNodeReferences(id)) {
-                    return true;
-                }
-            }
         } finally {
             readLock.release();
         }
+
+        // check virtual providers
+        for (int i = 0; i < virtualProviders.length; i++) {
+            if (virtualProviders[i].hasNodeReferences(id)) {
+                return true;
+            }
+        }
+
         return false;
     }