rabbitmq链接超时_网络故障后RabbitMQ集群未重新连接

当RabbitMQ遇到通信失败导致网络分区时,Mnesia会检测到这一情况并尝试恢复。在节点重新建立联系后,Mnesia可能会发送{inconsistent_database, running_partitioned_network, Node}系统事件。应用可以通过mnesia:set_master_nodes来指定从哪些节点加载表数据,以应对可能的不一致数据库。在启动时,Mnesia会跳过常规的表加载算法,从定义的主节点中加载表数据。mnesia:force_load_table函数则可以强制加载表,无视当前的加载机制。确保网络恢复后的数据一致性是Mnesia处理通信故障的关键部分。" 116524343,10856598,Java后端面试解析:Spring Cloud、数据库、并发与面试技巧,"['Java', '后端开发', '面试', 'Spring框架', '数据库']
摘要由CSDN通过智能技术生成

There are several occasions when Mnesia may detect that the network

has been partitioned due to a communication failure.

One is when Mnesia already is up and running and the Erlang nodes gain

contact again. Then Mnesia will try to contact Mnesia on the other

node to see if it also thinks that the network has been partitioned

for a while. If Mnesia on both nodes has logged mnesia_down entries

from each other, Mnesia generates a system event, called

{inconsistent_database, running_partitioned_network, Node} which is

sent to Mnesia's event handler and other possible subscribers. The

default event handler reports an error to the error logger.

Another occasion when Mnesia may detect that the network has been

partitioned due to a communication failure, is at start-up. If Mnesia

detects that both the local node and another node received mnesia_down

from each other it generates a {inconsistent_database,

starting_partitioned_network, Node} system event and acts as described

above.

If the application detects that there has been a communication failure

which may have caused an inconsistent database, it may use the

function mnesia:set_master_nodes(Tab, Nodes) to pinpoint from which

nodes each table may be loaded.

At start-up Mnesia's normal table load algorithm will be bypassed and

the table will be loaded from one of the master nodes defined for the

table, regardless of potential mnesia_down entries in the log. The

Nodes may only contain nodes where the table has a replica and if it

is empty, the master node recovery mechanism for the particular table

will be reset and the normal load mechanism will be used when next

restarting.

The function mnesia:set_master_nodes(Nodes) sets master nodes for all

tables. For each table it will determine its replica nodes and invoke

mnesia:set_master_nodes(Tab, TabNodes) with those replica nodes that

are included in the Nodes list (i.e. TabNodes is the intersection of

Nodes and the replica nodes of the table). If the intersection is

empty the master node recovery mechanism for the particular table will

be reset and the normal load mechanism will be used at next restart.

The functions mnesia:system_info(master_node_tables) and

mnesia:table_info(Tab, master_nodes) may be used to obtain information

about the potential master nodes.

Determining which data to keep after communication failure is outside

the scope of Mnesia. One approach would be to determine which "island"

contains a majority of the nodes. Using the {majority,true} option for

critical tables can be a way of ensuring that nodes that are not part

of a "majority island" are not able to update those tables. Note that

this constitutes a reduction in service on the minority nodes. This

would be a tradeoff in favour of higher consistency guarantees.

The function mnesia:force_load_table(Tab) may be used to force load

the table regardless of which table load mechanism is activated.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值