Hi Michael, The whole works :) except one improvement I want to make:
The deadlock was caused due to multiple threads (Akka Actor) updating the same Node or its relationships in parallel transaction. Is there a Neo4j way to avoid taking a transaction that would share objects with another one? Or should I play with classic (independent of Neo4j lib) thread synchronisation. On Friday, March 14, 2014 9:21:00 AM UTC+1, Michael Hunger wrote: > > Yep your code was correct except the tx close. > > You want to wrap that into a try-with-resource block, not sure how that > looks in scala. > > Remote server has no transactions (currently) each request is one tx. > > Cheers, > > Michael > > ---- > (michael > <http://twitter.com/mesirii>)-[:SUPPORTS]->(*YOU*)-[:USE]->(Neo4j<http://neo4j.org> > ) > Learn Online <http://neo4j.org/learn/online_course>, > Offline<http://www.neo4j.org/events> or > Read a Book <http://graphdatabases.com> (in Deutsch<http://bit.ly/das-buch> > ) > We're trading T-shirts for cool Graph Models <http://bit.ly/graphgist> > > > > > > > > Am 14.03.2014 um 03:18 schrieb Michael Azerhad > <[email protected]<javascript:> > >: > > I've just fixed the deadlock: I was missing the "tx.close()" statement at > the end of each of my transaction. > Now I seek for the reason why my cars is empty, after the save.. using > embedded mode. > When using REST mode, it still works. > > I would just like to have the confirmation that the way I exposed above is > correct. > I will then search myself for the reason :) > > Thanks a lot :) > > On Friday, March 14, 2014 2:57:16 AM UTC+1, Michael Azerhad wrote: >> >> It sounds to be a deadlock: >> >> A deadlock scenario has been detected and avoided. This means that two >> ormore transactions >> , which were holding locks, were wanting to await locks held by one >> another, which would have resulted in a deadlock between these >> transactions. This exception was thrown instead of ending up in that >> deadlock. >> >> >> See the deadlock section in the Neo4j manual for how to avoid this: http: >> //docs.neo4j.org/chunked/stable/transactions-deadlocks.html >> >> >> Details: 'Transaction(98, >> owner:"play-akka.actor.default-dispatcher-6")[STATUS_ACTIVE,Resources=1] >> can't wait on resource RWLock[NodeLock[id=0]] since => Transaction(98,owner >> :"play-akka.actor.default-dispatcher-6")[STATUS_ACTIVE,Resources=1] <-[: >> HELD_BY]- RWLock[NodeLock[id=3]] <-[:WAITING_FOR]- Transaction(101, owner >> :"play-akka.actor.default-dispatcher-9")[STATUS_ACTIVE,Resources=1] <-[: >> HELD_BY]- RWLock[NodeLock[id=0]]'. >> at >> org.springframework.data.neo4j.support.Neo4jExceptionTranslator.translateExceptionIfPossible(Neo4jExceptionTranslator.java:67) >> at >> org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) >> at >> org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) >> at >> org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) >> at >> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) >> at $Proxy57.save(Unknown Source) >> at >> com.myApp.infrastructure.persistence.user.Neo4jUserRepository.save(Neo4jUserRepository.scala:15) >> >> >> On Friday, March 14, 2014 2:45:17 AM UTC+1, Michael Hunger wrote: >>> >>> How does it fail? >>> D >>> Am 14.03.2014 um 01:54 schrieb Michael Azerhad <[email protected]>: >>> >>> Hi, >>> >>> I try to update the relationship of a Node that is a collection. >>> Example: User has a list of Cars. >>> >>> Firstly, I saved the User with the Cars set beforehand, and the whole >>> works with embedded mode and REST mode. >>> >>> Now, I want to add one Car to the list of this User. >>> >>> So I tried the following: (Scala code but easy to figure out) >>> >>> val tx = graphDatabaseService.beginTx() >>> val user = userRepository.findById(1) >>> user.cars.clear() //cars being the relationships (Set[Cars]) >>> user.cars.add(new Car("Ferrari")) >>> userRepository.save(user) // fail with embedded but >>> works with REST mode ! >>> tx.success() >>> >>> >>> Is it the right way to update the collection ? >>> Is there something special on the embedded mode handling ? >>> >>> Thanks, >>> >>> Michael >>> >>> >>> >>> >>> -- >>> 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. >>> >>> >>> > -- > 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.
