It's running in multi-threaded environment.
Lots of multi-threads are referencing them.
2014년 7월 3일 목요일 오후 8시 16분 43초 UTC+9, Lasse Westh-Nielsen 님의 말:
>
> try (Transaction tx = graphDb.beginTx())
> {
> boolean result = checkIfKnowsEdgeExists(startNode, endNode));
>
> if (!result) {
> makeKnowsEdge(startNode, endNode);
> tx.success();
> }
>
> should do it. you can't deadlock against yourself if you only create one
> transaction ;)
>
> - Lasse
>
>
>
> On Thu, Jul 3, 2014 at 1:09 PM, Frandro <[email protected] <javascript:>
> > wrote:
>
>> the parameters are a start node and end node.
>>
>> I'd like to check there's an edge named 'KNOWS' between them and connect
>> them with the edge.
>>
>> It's written in my java code as follows.
>> Transaction tx = graphDb.beginTx();
>> boolean result = checkIfKnowsEdgeExists(startNode, endNode));
>> tx.success();
>> tx.close();
>>
>> if (!result) {
>> Transaction tx = graphDb.beginTx();
>> makeKnowsEdge(startNode, endNode);
>> tx.success();
>> tx.close();
>> }
>>
>> The problem of the code above is it can be performed in 2 transactions.
>> I'd like to perform it in one transaction for performance, which creates
>> an edge when there's no such an edge.
>> Is there any better way to solve it? Cypher does not matter.
>>
>> The following code throws a deadlock related exception.
>> Transaction tx = graphDb.beginTx();
>>
>> boolean result = checkIfKnowsEdgeExists(startNode, endNode));
>>
>> if (!result) {
>> Transaction tx = graphDb.beginTx();
>> makeKnowsEdge(startNode, endNode);
>> tx.success();
>> tx.close();
>> }
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Neo4j" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.