incubator-clerezza-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hasan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLEREZZA-557) Potential Deadlock in UnionLock
Date Tue, 31 May 2011 14:55:47 GMT

    [ https://issues.apache.org/jira/browse/CLEREZZA-557?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041606#comment-13041606
] 

Hasan commented on CLEREZZA-557:
--------------------------------

It might be better to use the second tryLock method which allows to set a time span to wait
before giving up locking. Something like this:

@Override
public void lock() {
    while(!tryLock(10000, TimeUnit.NANOSECONDS)) {
  }
} 


> Potential Deadlock in UnionLock
> -------------------------------
>
>                 Key: CLEREZZA-557
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-557
>             Project: Clerezza
>          Issue Type: Bug
>            Reporter: Tsuyoshi Ito
>            Priority: Critical
>
> 2 Threads:
> Thread A and Thread B
> Thread A tries to set a writelock on UnionMGraph consisting of Graphs AG, BG, CG and
DG (AG is write locked, BG, CG, DG should be readlocked). BG and CG was successfully readlocked
by thread A but in the mean while Thread B tries to set a writelock on a UnionMGraph constisting
of DG, AG and EG. Thread B was able to writelock DG but has to wait for the readlock on AG
(is writelocked by thread A). thread A has to wait for the readlock on the graph DG =>
Deadlock
> I suggest to refactor lock in UnionLock as follows:
> @Override
> 		public void lock() {
> 			while(!tryLock()) {
> 				try {
> 					Thread.sleep(10);
> 				} catch (InterruptedException ex) {
> 					
> 				}
> 			}
> 		}
> instead of:
> @Override
> 		public void lock() {
> 			for(Lock lock : locks) {
> 				lock.lock();
> 				}
> 			}
> 		}
> I was able to reproduce it:
> ----------------------------------------------------
> http://tpf.localhost/content.graph
> Read-Lock count:    0
> Write-Locked:       YES
> Has queued threads: YES
> Thread holding write-lock: 
> java.lang.Throwable
> 	at java.lang.Thread.getStackTrace(Thread.java:1426)
> 	at org.apache.clerezza.rdf.core.access.debug.WriteLockDebug.lock(WriteLockDebug.java:55)
> 	at org.apache.clerezza.rdf.utils.UnionMGraph$UnionLock.lock(UnionMGraph.java:237)
> 	at org.clerezza.cms.utils.LockUtils.runLocked(LockUtils.java:66)
> 	at org.clerezza.app.conceptmanager.core.ConceptManager.getConcept(ConceptManager.java:169)
> 	at org.clerezza.app.conceptmanager.core.ConceptManager.storeConcept(ConceptManager.java:160)
> ......
> Queue length:       1
> Queued threads: 
> 42java.lang.Throwable
> 	at sun.misc.Unsafe.park(Native Method)
> 	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:877)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1197)
> 	at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(ReentrantReadWriteLock.java:594)
> 	at org.apache.clerezza.rdf.core.access.debug.ReadLockDebug.lock(ReadLockDebug.java:44)
> 	at org.apache.clerezza.rdf.utils.UnionMGraph$UnionLock.lock(UnionMGraph.java:237)
> ----------------------------------------------------
> http://tpf.localhost/feed.graph
> Read-Lock count:    0
> Write-Locked:       YES
> Has queued threads: YES
> Thread holding write-lock: 
> java.lang.Throwable
> 	at java.lang.Thread.getStackTrace(Thread.java:1426)
> 	at org.apache.clerezza.rdf.core.access.debug.WriteLockDebug.lock(WriteLockDebug.java:55)
> 	at org.apache.clerezza.rdf.core.access.LockableMGraphWrapper.remove(LockableMGraphWrapper.java:176)
> 	at org.apache.clerezza.rdf.utils.GraphNode.deleteProperties(GraphNode.java:536)
> ....
> Queue length:       1
> Queued threads: 
> 45java.lang.Throwable
> 	at sun.misc.Unsafe.park(Native Method)
> 	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:877)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1197)
> 	at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(ReentrantReadWriteLock.java:594)
> 	at org.apache.clerezza.rdf.core.access.debug.ReadLockDebug.lock(ReadLockDebug.java:44)
> 	at org.apache.clerezza.rdf.utils.UnionMGraph$UnionLock.lock(UnionMGraph.java:237)
> 	at org.apache.clerezza.rdf.utils.UnionMGraph$UnionLock.lock(UnionMGraph.java:237)
> 	at org.clerezza.cms.utils.LockUtils.runLocked(LockUtils.java:66)
> 	at org.clerezza.app.conceptmanager.core.ConceptManager.getConcept(ConceptManager.java:169)
> 	at org.clerezza.app.conceptmanager.core.ConceptManager.storeConcept(ConceptManager.java:160)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message