Hello, I have created a small test in java demonstrating this use case. If it is useful for you, please tell me where to upload/send it.
Regards, -- Daniel Martínez El mié, 11-11-2009 a las 17:10 +0100, Daniel Martínez escribió: > Hi and thanks for the answer, > > By close transaction I mean commit. The code as it is does not share > transactions. > > The problematic use case is: > > T1 begin > create rel 0 -> 1 > T1 commit > T1 begin > create rel 1 -> 2 > T2 begin > create rel 0 -> 3 <<<<<< deadlock > set property 3 > T2 commit > T1 set property 2 > T1 commit > > The case that works (with 0 -> 1 and 0 -> 3 already created): > > T1 begin > obtain 0 -> 1 > obtain 1 > T1 commit > T1 begin > create rel 1 -> 2 > T2 begin > obtain 0 -> 3 > set property 3 > T2 commit > T1 set property 2 > T1 commit > > The goal is having 0 -> 1 -> 2 and 0 -> 3 created. I suspect the problem > lies within node 0. Is it possible that T1 locks 0 when creating 1 -> 2? > > Regards, > -- > Daniel Martínez > > > El mié, 11-11-2009 a las 14:13 +0100, Johan Svensson escribió: > > > Hi, > > > > There is no global lock in Neo4j. We lock on a relationship and node level > > so: > > > > create node - write lock on created node (so other tx can't see until > > it exist for real) > > set/remove property - write lock on either the node or relationship > > create / delete relationship - write lock on the relationship and both > > nodes it is connected to > > > > There is however a special case during relationship create/delete. For > > a short period of time (during commit) a write lock may be grabbed on > > some other relationship (connected to the same node) while updating > > the "dual interleaved linked list" storing the relationships. > > > > I could not quite understand the use case you describe. By close you > > mean commit/rollback or suspend of transaction? If close means commit > > I get: > > > > T1 begin > > create rel 0 -> 1 > > T1 commit > > T1 begin > > create rel 1->2 > > T2 begin > > setProperty 2 // this will block since other open tx has created > > relationship to node 2 > > > > When T1 commits T2 can continue. > > > > Regards, > > -Johan > > > > On Wed, Nov 11, 2009 at 12:57 PM, Daniel Martínez > > <[email protected]> wrote: > > > Hi everyone, > > > > > > I am currently testing neo4j (1.0-b9)as a persistence layer for an app. > > > I have encountered an strange problem. > > > > > > I have two threads creating relations at the same time (both open > > > transactions) > > > > > > (0 is root node) > > > > > > T1(main): Begin transaction --> create relationship 0 -> 1 --> Close > > > Transaction --> Begin transaction --> create relationship 1 -> 2 --> > > > create T2 --> wait for T2 --> set property 2 --> .... --> Close > > > Transaction --> .... > > > T2: Begin transaction --> create relationship 0 -> 3 --> set property 3 > > > --> Close Transaction > > > > > > T1 is waiting for T2 to end, but it never does because of a deadlock. > > > Why is there such a deadlock? The nodes are not the same (concurrent > > > transactions for 1->2 and 0->3 creation). > > > > > > This does not occur during this situation > > > (0->1, 0->3 exist in database, 0 is root node) > > > > > > T1(main): Begin transaction --> obtain node 1 --> Close Transaction --> > > > Begin transaction --> create relationship 1->2 --> create T2 --> wait > > > for T2 --> set property 2 --> .... --> Close transaction --> .... > > > T2: Begin transaction --> Obtain 3 --> set property 3 --> Close > > > Transaction > > > > > > In this case both transactions commit correctly. > > > > > > Is there a global lock in neo4j when creating relationships? > > > > > > Thanks for your help, > > > -- > > > Daniel Martínez > > _______________________________________________ > > Neo mailing list > > [email protected] > > https://lists.neo4j.org/mailman/listinfo/user > > > > > ________________________ > > > > > > Soluciones de Gestión > para su empresa > > > > > eBusiness, ERP, CRM > > > > > > ________________________ > Daniel Martínez Martínez > > Gerente > C/ Julia García Boután, > 29 > 28022 Madrid > España > > > > > > > > > > E-mail: > [email protected] > Web: > www.paradisosistemas.es > Comercial: > [email protected] > Tel: 678416758 > > > > > > > > > _______________________________________________ > Neo mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user ________________________ Soluciones de Gestión para su empresa eBusiness, ERP, CRM ________________________ Daniel Martínez Martínez Gerente C/ Julia García Boután, 29 28022 Madrid España E-mail: [email protected] Web: www.paradisosistemas.es Comercial: [email protected] Tel: 678416758 _______________________________________________ Neo mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

