[Neo tickets] #209: Deadlock when creating relationship (concurrent threads)

neo4j.org noreply at neo4j.org
Thu Nov 12 15:27:24 CET 2009

#209: Deadlock when creating relationship (concurrent threads)
 Reporter:  dmm at paradisosistemas.es  |        Owner:  johans  
     Type:  bug report               |       Status:  assigned
 Priority:  major                    |    Milestone:          
Component:  neo                      |   Resolution:          
 Keywords:                           |  
Changes (by johans):

  * status:  new => assigned


 You are running in to the special case here as mentioned on the list. It
 is not the set property that blocks but the line before in T2, create rel
 0 ->. This is what happens:

 In second transaction of T1 (line 76 in attached test) the create rel 1 -
 > 2 will have to modify the relationship list for node 1. Node 1 already
 has a relationship incoming  from node 0. T1 will then lock the
 relationship between node 0 and 1 to modify the relationship list.

 T2 then tries to create a relationship between 0 -> 3, to do this it has
 to modify the relationship list for node 0 that is interleaved with the
 relationship list for node 1 so it will also try to lock the same

 Since you force T1 to wait for T2 to complete (which can not happen since
 T1 has the write lock on the relationship between 0 -> 1) it will
 deadlock. If you move the join and let T1 complete then wait for T2 it
 will complete without deadlock.

 There are other graphs layouts where your code will complete (if both node
 0 and node 1 have other relationships on them so the relationship from 0
 -> 1 is not the first in list to modify when creating 0 -> 3).

Ticket URL: <https://trac.neo4j.org/ticket/209#comment:1>
neo4j.org <http://trac.neo4j.org/>
The Neo4J.org Issue Tracker

More information about the Tickets mailing list