Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j "Can't wait on resource" lock error

I am using Node.js to connect to a hosted GrapheneDB Neo4j database and when attempting to add about 1,500 records I get the following error:

LockClient[19] can't wait on resource 
RWLock[NODE(248), hash=1917331445] since => LockClient[19] 
<-[:HELD_BY]- RWLock[INDEX_ENTRY(153122458561043471), hash=1171319680] 
<-[:WAITING_FOR]- LockClient[15] <-[:HELD_BY]- RWLock[NODE(248), hash=1917331445]

The code that generates this comes from a route that takes a list of JSON objects and then stores them in Neo4j. When importing approx 1,500 records I get this error consistently.

Using seraph-model to do the database accessing and just looking up the record, updating if it exists or creating it if it doesn't.

Any suggestions where to investigate?

like image 576
Dana Woodman Avatar asked Aug 26 '16 14:08

Dana Woodman


1 Answers

It looks like you're doing multiple large transactions concurrently hitting the same region of your graph.

When Neo4j performs a write, a write lock is acquired on that node/relationship and released when the transactions is closed. Other transaction running concurrently who try to acquire a write lock on a already locked entity need to wait - otherwise a box of pandora's inconsistencies would have had opened. If the owner of the lock is a rather long running transaction, the other one might run into a timeout - that would be the above error message.

So you can either:

  1. serialize the operations: don't do writes in parallel, instead make sure only one fat transaction is processed at a given time
  2. make transactions smaller: if you do less in a singe transaction, the duration will be shorter and other transactions waiting for locks won't timeout.
like image 159
Stefan Armbruster Avatar answered Nov 09 '22 16:11

Stefan Armbruster