简体   繁体   中英

How to acquire write lock on a node?

I want to do something like this (ruby, cypher queries):

// ACQUIRE WRITE LOCK ON NODE 1

// SOME CODE THAT DO READ AND THEN WRITE, eg:

results = neo.query("MATCH (n {id: 1}) RETURN n")
...
case results.size
  when 0
    neo.create_node(properties)
  when 1
    neo.update_node(results.first, properties)
...

// RELEASE WRITE LOCK ON NODE 1

According to docs, http://docs.neo4j.org/chunked/stable/transactions-isolation.html :

By default a read operation will read the last committed value unless a local modification within the current transaction exist. The default isolation level is very similar to READ_COMMITTED: reads do not block or take any locks so non-repeatable reads can occur. It is possible to achieve a stronger isolation level (such as REPETABLE_READ and SERIALIZABLE) by manually acquiring read and write locks.

http://docs.neo4j.org/chunked/stable/transactions.html :

One can manually acquire write locks on nodes and relationships to achieve higher level of isolation (SERIALIZABLE).

But there is nowhere mentioned anything about how to acquire the lock or how to change the isolation level.

There is no support at the moment for overriding the default READ_COMMITTED isolation level through the REST API. Manually overriding isolation level can be achieved only if using Neo4j embedded in your Java application.

We'll add a note to the documentation page you referenced to make that a bit more clear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM