You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2014/01/22 21:37:42 UTC
svn commit: r1560503 - in
/manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager:
LockGate.java LockObject.java
Author: kwright
Date: Wed Jan 22 20:37:42 2014
New Revision: 1560503
URL: http://svn.apache.org/r1560503
Log:
Disable ordering constraint; tests now pass
Modified:
manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java
manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java
Modified: manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java?rev=1560503&r1=1560502&r2=1560503&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java (original)
+++ manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockGate.java Wed Jan 22 20:37:42 2014
@@ -40,13 +40,34 @@ import org.apache.manifoldcf.core.interf
* } finally {
* <release_permission>
* }
-* Problem: Delay in obtaining a lock causes LockGate to "back up". This is because
-* the thread ID is not removed before the thread blocks waiting to get the lock.
-* One solution: Don't block while holding permission open. But this defeats the whole
-* point of the priority queue, which is to reserve locks in the order they are requested.
-* A second solution is to work through threadRequests object notifications so that we
-* can break out of those waits too. So there may be a lockpool reference locked against threadRequests
-* that also gets cleared etc.
+* Seeing lockups. These lockups are characterized by a thread waiting on a lock object
+* while another thread waits on permission to do something else with the lock object.
+* It is by no means clear at this point how this situation causes a hang-up; the
+* lock object is waiting to be awakened, but there is no obvious entity holding the lock elsewhere.
+* But one thread (A) seems always to be in a multi-lock situation, waiting to obtain a lock, e.g.:
+ at java.lang.Object.wait(Native Method)
+ at java.lang.Object.wait(Object.java:503)
+ at org.apache.manifoldcf.core.lockmanager.LockObject.enterWriteLock(LockObject.java:80)
+ - locked <0x00000000fe205720> (a org.apache.manifoldcf.core.lockmanager.LockObject)
+ at org.apache.manifoldcf.core.lockmanager.LockGate.enterWriteLock(LockGate.java:132)
+ at org.apache.manifoldcf.core.lockmanager.BaseLockManager.enter(BaseLockManager.java:1483)
+ at org.apache.manifoldcf.core.lockmanager.BaseLockManager.enterCriticalSections(BaseLockManager.java:920)
+ at org.apache.manifoldcf.core.lockmanager.LockManager.enterCriticalSections(LockManager.java:455)
+* Here's the second thread (B), which is waitingForPermission:
+ at java.lang.Object.wait(Native Method)
+ - waiting on <0x00000000f8b71c78> (a org.apache.manifoldcf.core.lockmanager.LockGate)
+ at java.lang.Object.wait(Object.java:503)
+ at org.apache.manifoldcf.core.lockmanager.LockGate.waitForPermission(LockGate.java:91)
+ - locked <0x00000000f8b71c78> (a org.apache.manifoldcf.core.lockmanager.LockGate)
+ at org.apache.manifoldcf.core.lockmanager.LockGate.enterWriteLock(LockGate.java:129)
+ at org.apache.manifoldcf.core.lockmanager.BaseLockManager.enterWrite(BaseLockManager.java:1130)
+ at org.apache.manifoldcf.core.lockmanager.BaseLockManager.enterWriteCriticalSection(BaseLockManager.java:896)
+ at org.apache.manifoldcf.core.lockmanager.LockManager.enterWriteCriticalSection(LockManager.java:431)
+ at org.apache.manifoldcf.core.interfaces.IDFactory.make(IDFactory.java:55)
+* The problem is that (A) has already obtained permission, but cannot obtain the lock. (B) is somehow blocking
+* (A) from obtaining the lock even though it has not yet taken its own lock! Or, maybe it has, and we don't see it in
+* the stack trace.
+* Debugging must entail dumping ALL outstanding locks periodically -- and who holds each.
*/
public class LockGate
{
@@ -126,28 +147,28 @@ public class LockGate
public void enterWriteLock(Long threadID)
throws ManifoldCFException, InterruptedException, ExpiredObjectException
{
- waitForPermission(threadID);
+ //waitForPermission(threadID);
try
{
lockObject.enterWriteLock();
}
finally
{
- freePermission(threadID);
+ //freePermission(threadID);
}
}
public void enterWriteLockNoWait(Long threadID)
throws ManifoldCFException, LockException, LocalLockException, InterruptedException, ExpiredObjectException
{
- waitForPermission(threadID);
+ //waitForPermission(threadID);
try
{
lockObject.enterWriteLockNoWait();
}
finally
{
- freePermission(threadID);
+ //freePermission(threadID);
}
}
@@ -167,28 +188,28 @@ public class LockGate
public void enterNonExWriteLock(Long threadID)
throws ManifoldCFException, InterruptedException, ExpiredObjectException
{
- waitForPermission(threadID);
+ //waitForPermission(threadID);
try
{
lockObject.enterNonExWriteLock();
}
finally
{
- freePermission(threadID);
+ //freePermission(threadID);
}
}
public void enterNonExWriteLockNoWait(Long threadID)
throws ManifoldCFException, LockException, LocalLockException, InterruptedException, ExpiredObjectException
{
- waitForPermission(threadID);
+ //waitForPermission(threadID);
try
{
lockObject.enterNonExWriteLockNoWait();
}
finally
{
- freePermission(threadID);
+ //freePermission(threadID);
}
}
@@ -208,28 +229,28 @@ public class LockGate
public void enterReadLock(Long threadID)
throws ManifoldCFException, InterruptedException, ExpiredObjectException
{
- waitForPermission(threadID);
+ //waitForPermission(threadID);
try
{
lockObject.enterReadLock();
}
finally
{
- freePermission(threadID);
+ //freePermission(threadID);
}
}
public void enterReadLockNoWait(Long threadID)
throws ManifoldCFException, LockException, LocalLockException, InterruptedException, ExpiredObjectException
{
- waitForPermission(threadID);
+ //waitForPermission(threadID);
try
{
lockObject.enterReadLockNoWait();
}
finally
{
- freePermission(threadID);
+ //freePermission(threadID);
}
}
Modified: manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java?rev=1560503&r1=1560502&r2=1560503&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java (original)
+++ manifoldcf/branches/CONNECTORS-867/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockObject.java Wed Jan 22 20:37:42 2014
@@ -57,9 +57,6 @@ public class LockObject
public synchronized void enterWriteLock()
throws ManifoldCFException, InterruptedException, ExpiredObjectException
{
- if (lockPool == null)
- throw new ExpiredObjectException("Invalid");
-
while (true)
{
if (lockPool == null)
@@ -140,22 +137,10 @@ public class LockObject
if (obtainedWrite == false)
throw new RuntimeException("JVM failure: Don't hold lock for object "+this.toString());
- obtainedWrite = false;
- try
- {
- clearGlobalWriteLock();
- }
- catch (Error e)
- {
- obtainedWrite = true;
- throw e;
- }
- catch (RuntimeException e)
- {
- obtainedWrite = true;
- throw e;
- }
+
+ clearGlobalWriteLock();
+ obtainedWrite = false;
notifyAll();
}
@@ -269,25 +254,15 @@ public class LockObject
if (obtainedNonExWrite == 0)
throw new RuntimeException("JVM error: Don't hold lock for object "+this.toString());
- obtainedNonExWrite--;
- if (obtainedNonExWrite > 0)
- return;
-
- try
- {
- clearGlobalNonExWriteLock();
- }
- catch (Error e)
+ if (obtainedNonExWrite > 1)
{
- obtainedNonExWrite++;
- throw e;
- }
- catch (RuntimeException e)
- {
- obtainedNonExWrite++;
- throw e;
+ obtainedNonExWrite--;
+ return;
}
+ clearGlobalNonExWriteLock();
+
+ obtainedNonExWrite--;
notifyAll();
}
@@ -390,24 +365,15 @@ public class LockObject
if (obtainedRead == 0)
throw new RuntimeException("JVM error: Don't hold lock for object "+this.toString());
- obtainedRead--;
- if (obtainedRead > 0)
- return;
- try
+ if (obtainedRead > 1)
{
- clearGlobalReadLock();
- }
- catch (Error e)
- {
- obtainedRead++;
- throw e;
- }
- catch (RuntimeException e)
- {
- obtainedRead++;
- throw e;
+ obtainedRead--;
+ return;
}
+
+ clearGlobalReadLock();
+ obtainedRead--;
notifyAll();
}