是否可以为关系覆盖Neo4j锁定行为? [英] Is it possible to override Neo4j lock behavior for relationships?

查看:146
本文介绍了是否可以为关系覆盖Neo4j锁定行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅: http://neo4j.com/docs/stable/transactions-locking. html 创建或删除关系时,将对特定关系及其两个节点进行写锁定"

See: http://neo4j.com/docs/stable/transactions-locking.html "When creating or deleting a relationship a write lock will be taken on the specific relationship and both its nodes"

假设我需要在一个事务中创建许多关系.我不在乎锁定与这些关系连接的节点.特别是,对于其他并发事务: 1)在这些节点上更新属性不会干扰我的操作 2)创建或删除与这些节点的 other 关系不会干扰我的操作

Suppose I need to create many relationships within a transaction. I don't care about locking on the nodes that are connected to those relationships. In particular, for other concurrent transactions: 1) Updating properties on those nodes does not interfere with my operation 2) Creating or removing other relationships to those nodes would not interfere with my operation

默认锁定行为"在某些情况下会产生大量争用并可能导致死锁.例如,我有一个由30个节点组成的集合X,两个事务正在同时创建新节点,这些新节点与X中的每个节点都有关系.死锁很有可能.

The "default locking behavior" generates a huge amount of contention and possibilities for deadlocks in some cases. For example, I have a set X of 30 nodes, and two transactions are concurrently creating new nodes that have relationships to each node in X. That requires each transaction to get a write lock on all 30 nodes in X; deadlock is a strong possibility.

将该行为描述为默认",听起来可以覆盖此行为.如果是这样,我该怎么办?

The description of the behavior as "default" makes it sound like it is possible to override this behavior. If so, how can I do this?

(更多背景信息:系统通常使用Spring Data Neo4j和Cypher查询与数据库进行交互.)

(More background: the system normally uses Spring Data Neo4j and Cypher queries to interact with the database.)

推荐答案

无法覆盖锁定行为. Neo4j曾经支持多种隔离级别,因此,"default"一词可能是从那时开始的,因此页面需要更新.

It's not possible to override the locking behaviour. Neo4j used to support multiple isolation levels, so it might be that the word "default" is from that time and that the page needs an update.

在Neo4j中,您不能删除具有关系的节点.我认为这就是为什么在创建关系时它会锁定节点.不幸的是,它干扰了修改属性和其他关系.

In Neo4j, you can't delete a node that has relationships. I think that's why it locks the nodes when you create relationships. That it interferes with modifying properties and other relationships is unfortunate.

如果可以自由使用图模型,则可以引入关系节点,竞争节点可以将其易失性关系委托给该关系节点.这样,您就可以以更复杂的图形为代价来剥离锁.

If you can take liberties with your graph model, you can introduce relation-nodes that the contended nodes can delegate their volatile relationships to. That way you stripe the locks at the cost of a more complicated graph.

这篇关于是否可以为关系覆盖Neo4j锁定行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆