MariaDB Galera集群引用完整性约束

时间:2022-09-19 20:20:42

We are in the process of evaluating MariaDB Galera cluster for our application. As I understand the cluster supports row level and statement level replication. We are leaning towards the row level replication. Our data model has multiple entities related to each other. We are going to have foreign key relationships among the entities.

我们正在为我们的应用程序评估MariaDB Galera集群。正如我所理解的,集群支持行级和语句级复制。我们倾向于行级复制。我们的数据模型有多个相互关联的实体。我们将在各实体之间建立外交关系。

Would like to understand if we go with row based replication how the cluster would handle the following scenario.

如果我们使用基于行的复制,希望了解集群将如何处理以下场景。

1> The cluster has 3 nodes

集群有3个节点

2> There are entities like Class and Student. In this we have a foreign key Student -> Class

有一些实体像班级和学生。在这里我们有一个外国重点学生->班

3> We get two nodes (N1 & N2) get two separate updates from two different transactions

>我们得到两个节点(N1和N2)从两个不同的事务中获得两个独立的更新

A) At time t1 : Node N1 gets inserts for a students(s1 and s2) for a particular classes c1 and c2 respectively.

A)时刻t1:节点N1分别为一个学生(s1和s2)获取针对一个特定类c1和c2的插入。

B) At time t2 : The class c1 gets deleted from node N2

B)时刻t2:从节点N2中删除类c1

C) At time t3 : The change (addition of the student s1 and s2) gets pushed from N1 to N2

C)时间t3:变化(学生s1和s2的增加)从N1推到N2

Would the entire transaction involving the students addition would be rolled back?

是否会回滚涉及学生加法的整个交易?

1 个解决方案

#1


2  

RBR only.

RBR。

At the time of COMMIT, you must check for errors. This is the time at which conflicts are checked with other nodes.

在提交时,必须检查错误。这是与其他节点检查冲突的时间。

That is, one node may have no conflicts, only to find out (at COMMIT) that what looked good on that node will collide with whatever was simultaneously happening on other node(s).

也就是说,一个节点可能没有冲突,只需要(在提交时)发现该节点上看起来好的内容将与其他节点上同时发生的内容发生冲突。

More Galera tips

更多Galera技巧

In general, whenever you get "deadlock", simply rerun the entire transaction. It will probably work the second time (or encounter some other error, now that the remote transaction has made it the current node).

通常,当您遇到“死锁”时,只需重新运行整个事务。它可能会第二次工作(或者遇到其他错误,因为远程事务已经将它设置为当前节点)。

#1


2  

RBR only.

RBR。

At the time of COMMIT, you must check for errors. This is the time at which conflicts are checked with other nodes.

在提交时,必须检查错误。这是与其他节点检查冲突的时间。

That is, one node may have no conflicts, only to find out (at COMMIT) that what looked good on that node will collide with whatever was simultaneously happening on other node(s).

也就是说,一个节点可能没有冲突,只需要(在提交时)发现该节点上看起来好的内容将与其他节点上同时发生的内容发生冲突。

More Galera tips

更多Galera技巧

In general, whenever you get "deadlock", simply rerun the entire transaction. It will probably work the second time (or encounter some other error, now that the remote transaction has made it the current node).

通常,当您遇到“死锁”时,只需重新运行整个事务。它可能会第二次工作(或者遇到其他错误,因为远程事务已经将它设置为当前节点)。