[infinispan-dev] deadlock detection on local caches
Manik Surtani
manik at jboss.org
Thu Jul 9 06:59:17 EDT 2009
On 8 Jul 2009, at 20:16, Mircea Markus wrote:
> Hi,
>
> Original design[1] treats the situation in which two replicating
> transaction are in a deadlock.
> Here is an idea for a similar mechanism intended for detecting
> deadlocks on a local cache.
>
> T1, T2 two transactions running on the same local cache.
> T1 has lock on k1 and tries to acquire k2
> T2 has lock on k2 and tries to acquire k1
>
> Each thread runs the following algorithm, (similar to one described
> in [1])
>
> lock(int timeout)
> {
> while (currentTime < startTime + timeout)
> {
> if (acquire(smallTimeout)) break;
> testEDD(globalTransaction, key);
> }
> }
>
>
>
> //will run the same algorithm, by both T1 and T2:
> //globalTransaction - this is the tx that couldn't acquire lock in
> 'smallTimeout'
> //key - the key that couldn't be locked by globalTransation
>
> testEDD(globalTransaction, key)
> globalTransaction.setLockIntention(key); //we intend to lock the
> given key...
> Object lockOwner = getLockOwner(key);
> if (isLocallyOriginatedTx(lockOwner)) {
> Object keyToBeLocked = lockOwner.getLockIntention(); if
> (globalTransaction.ownsLock(keyToBeLocked)) {
surely you mean lockManager.ownsLock(globalTransaction, key).
But yes, this would be handy to break deadlocks on local transactions.
> //this is a deadlock situation
> //use coin toss to determine which tx should rollback!!!
> return;
> } else {
> return; //this will go back to the main loop in 'lock(int timeout)'
> method
> }
> }
>
> Cheers,
> Mircea
>
>
> [1] http://tinyurl.com/nunmyu
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev
--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org
More information about the infinispan-dev
mailing list