jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1087304 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/DefaultISMLocking.java
Date Thu, 31 Mar 2011 14:06:56 GMT
Author: jukka
Date: Thu Mar 31 14:06:56 2011
New Revision: 1087304

URL: http://svn.apache.org/viewvc?rev=1087304&view=rev
Log:
JCR-2890: Deadlock in acl.EntryCollector / ItemManager

Make it possible to switch from writer to reader preference in
the DefaultISMLocking class. This makes it possible to work around
this specific issue, though there may be consequences to write performance
during heavy concurrent read loads. Note that the FineGrainedISMLocking
strategy prefers readers.

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

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/DefaultISMLocking.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/DefaultISMLocking.java?rev=1087304&r1=1087303&r2=1087304&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/DefaultISMLocking.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/DefaultISMLocking.java
Thu Mar 31 14:06:56 2011
@@ -51,6 +51,14 @@ public class DefaultISMLocking implement
     };
 
     /**
+     * Flag for determining whether this locking strategy should give
+     * preference to writers or not. If writers are preferred (which
+     * is the default setting), then all readers will get blocked whenever
+     * there's a writer waiting for the lock.
+     */
+    private boolean writerPreference = true;
+
+    /**
      * Number of writer threads waiting. While greater than zero, no new
      * (unrelated) readers are allowed to proceed.
      */
@@ -79,6 +87,24 @@ public class DefaultISMLocking implement
     private int readerCount = 0;
 
     /**
+     * Returns the writer preference status of this locking strategy.
+     *
+     * @return writer preference
+     */
+    public boolean isWriterPreference() {
+        return writerPreference;
+    }
+
+    /**
+     * Sets the writer preference status of this locking strategy.
+     *
+     * @param preference writer preference
+     */
+    public void setWriterPreference(boolean preference) {
+        this.writerPreference = preference;
+    }
+
+    /**
      * Increments the reader count and returns the acquired read lock once
      * there are no more writers or the current writer shares the thread id
      * with this reader.
@@ -88,7 +114,7 @@ public class DefaultISMLocking implement
         Object currentId = getCurrentThreadId();
         while (writerId != null
                 ? (writerCount > 0 && !isSameThreadId(writerId, currentId))
-                : writersWaiting > 0) {
+                : (writerPreference && writersWaiting > 0)) {
             wait();
         }
 



Mime
View raw message