Hello David, Sorry for the delayed response.
Unfortunately I cannot share the store directory because we are doing the tests with our production data. The code is exactly as the one I've shared at the beginning of this discussion thread with the addition of the locking mechanism proposed by Johan. Taking a second look over that locking mechanism, I've noticed that it uses read locks for a delete operation. Should there be write locks instead? Thank you, George -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of David Montag Sent: 17 December 2010 16:43 To: Neo4j user discussions Subject: Re: [Neo4j] InvalidRecordException exception Hi George, If you would like to share your code, or really any code that reproduces this, along with the store directory, it would be easier for us to help you. David On Fri, Dec 17, 2010 at 5:00 AM, George Ciubotaru < [email protected]> wrote: > Hello Johan, > > Unfortunately the proposed solution to lock the delete operation din't > solve the issue. I'm still getting the InvalidRecordException > exception but not as often. I'm getting instead a deadlock exception: > > Caused by: org.neo4j.kernel.DeadlockDetectedException: > Transaction(113733)[STATUS_ACTIVE,Resources=0] can't wait on resource > RWLock[Relationship[2221154]] since => > Transaction(113733)[STATUS_ACTIVE,Resources=0] <- > RWLock[Relationship[2221154]] <- > Transaction(113733)[STATUS_ACTIVE,Resources=0] <- > RWLock[Relationship[2221154]] > at > org.neo4j.kernel.impl.transaction.RagManager.checkWaitOnRecursive(RagManager.java:219) > at > org.neo4j.kernel.impl.transaction.RagManager.checkWaitOnRecursive(RagManager.java:247) > at > org.neo4j.kernel.impl.transaction.RagManager.checkWaitOn(RagManager.java:186) > at > org.neo4j.kernel.impl.transaction.RWLock.acquireWriteLock(RWLock.java:300) > at > org.neo4j.kernel.impl.transaction.LockManager.getWriteLock(LockManager.java:129) > at > org.neo4j.kernel.impl.core.NodeManager.acquireLock(NodeManager.java:684) > at > org.neo4j.kernel.impl.core.RelationshipImpl.delete(RelationshipImpl.java:143) > at > org.neo4j.kernel.impl.core.RelationshipProxy.delete(RelationshipProxy.java:50) > at Graphing.Graph.deleteRelationships(Graph.java:1257) > > I'm not using any lock mechanism other than the one you've proposed > and that only for that delete operation. Any idea of might be wrong here? > > Thank you, > George > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] > On Behalf Of Johan Svensson > Sent: 15 December 2010 13:32 > To: Neo4j user discussions > Subject: Re: [Neo4j] InvalidRecordException exception > > This will still happen in the 1.2.M05 release. I just wanted to make > sure I linked the stacktrace's line numbers to the right part of the > code since that exception being thrown at a different place in the > delete method could mean there are other problems. > > > -Johan > > On Wed, Dec 15, 2010 at 1:42 PM, George Ciubotaru < > [email protected]> wrote: > > Yes, the version I'm currently using is 1.1. Shall I understand that > > this > kind of issue shouldn't occur in 1.2.M05? > > > > For the moment I'll take the pessimistic approach by guarding > > against (as > in the example you gave) to assure that this is the reason and then > I'll just accept the exception. > > > > Thank you for your quick and detailed response. > > > > Best regards, > > George > > > > > > -----Original Message----- > > From: [email protected] > > [mailto:[email protected]] On Behalf Of Johan Svensson > > Sent: 15 December 2010 12:23 > > To: Neo4j user discussions > > Subject: Re: [Neo4j] InvalidRecordException exception > > > > Sorry, should also have asked what Neo4j version you use but > > guessing it > is 1.1 or early milestone release? > > > > If so I think the problem is caused by two or more concurrent > transactions running delete on the same relationship. If two > transactions get a reference to the same relationship and concurrently > delete that relationship it is possible for a InvalidRecordException > to be thrown instead of a NotFoundException since the write lock is > grabbed after the relationship has been verified to exist. > > > > Solution is either to accept the exception or to guard against it by > first acquiring a read lock on the relationship before invoking > relationship.delete(). Code example how to do this: > > > > GraphDatabaseService gdb; // the graph db > > Relationship relationship; // the relationship to delete > > > > LockManager lockManager = ((EmbeddedGraphDatabase) > > gdb).getConfig().getLockManager(); > > lockManager.getReadLock( relationship ); > > try > > { > > relationship.delete(); > > } > > finally > > { > > lockManager.releaseReadLock( relationship ); > > } > > > > Regards, > > Johan > > > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > -- David Montag Neo Technology, www.neotechnology.com Cell: 650.556.4411 [email protected] _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

