Hi Mattias,

Thanks for the docs.
I'm trying to solve this issue now and here is the problem I'm facing...

Where it says in the wiki:
"Rewrite your code, making sure that such scenarios won't happen.
Run your deadlock-prone code in a try-catch(DeadlockDetectedException)
block and just rerun the entire transaction if such an exception is
caught."

My transactions start and end in an interceptor that provides advice
to method invokations.
The invokations happen inside a thread pool concurrently.

This is what the interceptor looks like. I have no way to recover from
the deadlock. Are you implying in that advice that
I should synchronize in the operation that is causing the write lock?
Is there anyway to configure Neo to wait on deadlock for a release up
to certain time?
If I reissue a method call that is transactional other state not
related to the neo transactions such as indexes, etc... may modify
other state objects, I'd rather have the transaction wait for release
and continue as other transactions are completing.

Here is the code for the interceptor. The advised methods are
Runnables that get executed async by a threadpool.

/**
 * A method interceptor that provides transaction advice around a
method invocation opening and closing a transaction accordingly
 */
public class Neo4JTransactionAdviceInterceptor implements MethodInterceptor {

    private final static Logger log =
Logger.getLogger(Neo4JTransactionAdviceInterceptor.class);

    private GraphDatabaseService neoService;

    public void setNeoService(GraphDatabaseService neoService) {
        this.neoService = neoService;
    }

    /**
     * provides transaction advice around a method invocation opening
and closing a transaction accordingly
     *
     * @param invocation the method invocation joinpoint
     * @return the result of the call to {...@link
     *         org.aopalliance.intercept.Joinpoint#proceed()}, might
be intercepted by the
     *         interceptor.
     * @throws Throwable if the interceptors or the
     *                   target-object throws an exception.
     */
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Transaction tx = neoService.beginTx();
        Object result = null;
                try {
                        result = invocation.proceed();
                        tx.success();
                } catch (DeadlockDetectedException e) {
            tx.failure();
            log.debug("deadlock detected for invocation " + invocation
+ " result: " + result + " transaction: " + tx);
        } catch (Throwable t) {
                        tx.failure();
            throw t;
                } finally {
                        tx.finish();
                }
        return result;
    }
}


2010/2/22 Mattias Persson <[email protected]>:
> I wrote a reply to this, but decided to put it on the wiki instead...
> so head over to http://wiki.neo4j.org/content/Transactions#Deadlocks
> and read all about it :)
>
> 2010/2/22 Raul Raja Martinez <[email protected]>:
>> Hi,
>>
>> I have some code that runs in parallel through a Thread pool executor.
>> I'm getting the following exception:
>>
>> publish exception: class
>> org.neo4j.kernel.impl.transaction.DeadlockDetectedException :
>> Transaction[Status=STATUS_ACTIVE,ResourceList=Xid[GlobalId[NEOKERNL|1266821950597|383448],
>> BranchId[ 52 49 52 49 52 49 ]]
>> xaresource[org.neo4j.kernel.impl.nioneo.xa.neostorexaconnection$neostorexaresou...@16107eff]
>> Status[ENLISTED] can't wait on resource RWLock[NodeImpl#9058] since =>
>> Transaction[Status=STATUS_ACTIVE,ResourceList=Xid[GlobalId[NEOKERNL|1266821950597|383448],
>> BranchId[ 52 49 52 49 52 49 ]]
>> xaresource[org.neo4j.kernel.impl.nioneo.xa.neostorexaconnection$neostorexaresou...@16107eff]
>> Status[ENLISTED] <- RWLock[NodeImpl#187780] <-
>> Transaction[Status=STATUS_ACTIVE,ResourceList=Xid[GlobalId[NEOKERNL|1266821950597|383448],
>> BranchId[ 52 49 52 49 52 49 ]]
>> xaresource[org.neo4j.kernel.impl.nioneo.xa.neostorexaconnection$neostorexaresou...@16107eff]
>> Status[ENLISTED] <- RWLock[NodeImpl#9058]
>> at
>> com.cirqe.api.persistence.graph.impl.neo4j.Neo4JGraphNodeProxy.invoke(Neo4JGraphNodeProxy.java:127)
>>
>> I thought I'd post it since we have not seen this until we have upgraded to
>> the latest version.
>>
>> Thanks in advance!
>>
>> Raul
>> _______________________________________________
>> Neo mailing list
>> [email protected]
>> https://lists.neo4j.org/mailman/listinfo/user
>>
>
>
>
> --
> Mattias Persson, [[email protected]]
> Neo Technology, www.neotechnology.com
> _______________________________________________
> Neo mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Raul Raja
_______________________________________________
Neo mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to