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

查看:11
本文介绍了是否可以覆盖关系的 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)创建或删除与这些节点的其他关系不会干扰我的操作

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 中的每个节点都有关系.这要求每个事务在 X 中的所有 30 个节点上获得写锁;死锁的可能性很大.

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 曾经支持多个隔离级别,所以可能是默认"这个词来自那个时候,页面需要更新.

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天全站免登陆