关于mnesia分布的问题 [英] question about mnesia distribution

查看:111
本文介绍了关于mnesia分布的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个节点运行mnesia。我在节点1 上创建了模式和一些表,并在节点2上使用 mnesia:add_table_copy

I have two nodes running mnesia. I created schema and some tables on node 1, and used mnesia:add_table_copy on node 2 to copy the tables from node 1 to node 2.

一切正常,直到我调用 q()然后在节点2 上的 q()我发现当我再次启动节点1 时, mnesia:wait_for_tables([sometable],infinity)它只会在我再次启动节点2 时返回。

Everything works well until I call q() on node 1 and then q() on node 2. I found that when I start node 1 again, mnesia:wait_for_tables([sometable], infinity) won't return. It will only return when I start node 2 again.

有办法解决这个问题吗?这是一个问题,因为如果节点2 关闭,我将无法再次启动节点1

Is there a way to fix this? This is a problem because I won't be able to start node 1 again if node 2 is down.

推荐答案

In this discussion a situation similar to the one you're facing is presented.

从这个来源阅读:


在启动时Mnesia尝试连接
和其他节点,如果
不合格,它从
加载它的表。如果其他节点关闭,它

本地事务日志中查找mnesia_down标记,以便
确定它是否具有一致的
副本或其表。最后关闭的节点
有来自所有其他
节点的
mnesia_down。这意味着它可以安全地
加载它的表。如果某些其他
节点首先启动(如在
情况下),Mnesia将无限期地等待另一个节点连接,按顺序
加载它的表

At startup Mnesia tries to connect with the other nodes and if that suceeds it loads its tables from them. If the other nodes are down, it looks for mnesia_down marks in its local transaction log in order to determine if it has a consistent replica or not of its tables. The node that was shutdown last has mnesia_down's from all the other nodes. This means that it safely can load its tables. If some of the other nodes where started first (as in your case) Mnesia will wait indefinitely for another node to connect in order to load its tables

您正在关闭节点1,因此它没有 mnesia_down 另一个节点。

You're shutting down node 1 first, so it doesn't have the mnesia_down from the other node. What happens if you reverse the shutting down order?

此外,应该可以通过 force_load_table / 1 功能:

Also, it should be possible to force the table loading via the force_load_table/1 function:

force_load_table(Tab) -> yes | ErrorDescription




表装载
的Mnesia算法可能导致无法加载
表的情况。这种情况
发生在节点启动时,
Mnesia结束或怀疑
表的另一个副本是活动的
在本地副本变为非活动后
到期系统崩溃。

The Mnesia algorithm for table load might lead to a situation where a table cannot be loaded. This situation occurs when a node is started and Mnesia concludes, or suspects, that another copy of the table was active after this local copy became inactive due to a system crash.

如果这种情况不被接受,
这个函数可以用来覆盖
Mnesia表的策略load
算法。这可能导致
情况,其中一些事务
效果丢失与作为结果的不一致的
数据库,但对于一些
应用程序高可用性更多
比一致性数据。

If this situation is not acceptable, this function can be used to override the strategy of the Mnesia table load algorithm. This could lead to a situation where some transaction effects are lost with a inconsistent database as result, but for some applications high availability is more important than consistent data.

这篇关于关于mnesia分布的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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