summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2013-08-22 15:44:39 +0100
committerEmile Joubert <emile@rabbitmq.com>2013-08-22 15:44:39 +0100
commit536bf6cb36806f9163507d96b0e669bc7fdf9d44 (patch)
treecda45abded4c08c58379c5f84dbd5362f8f7db52
parent13846f921e79ed9924a8a56da74f5cfda88ddb0d (diff)
downloadrabbitmq-server-536bf6cb36806f9163507d96b0e669bc7fdf9d44.tar.gz
Solve startup conflict between nodes by restarting slave runtime
-rw-r--r--src/rabbit_mirror_queue_slave.erl47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 54ee7129..ec6e500f 100644
--- a/src/rabbit_mirror_queue_slave.erl
+++ b/src/rabbit_mirror_queue_slave.erl
@@ -137,28 +137,39 @@ init(Q = #amqqueue { name = QName }) ->
{stop, {duplicate_live_master, Node}};
existing ->
gm:leave(GM),
+ ignore;
+ master_recovery_detected ->
+ init:restart(),
ignore
end.
init_it(Self, GM, Node, QName) ->
- [Q = #amqqueue { pid = QPid, slave_pids = SPids, gm_pids = GMPids }] =
- mnesia:read({rabbit_queue, QName}),
- case [Pid || Pid <- [QPid | SPids], node(Pid) =:= Node] of
- [] -> add_slave(Q, Self, GM),
- {new, QPid, GMPids};
- [QPid] -> case rabbit_misc:is_process_alive(QPid) of
- true -> duplicate_live_master;
- false -> {stale, QPid}
- end;
- [SPid] -> case rabbit_misc:is_process_alive(SPid) of
- true -> existing;
- false -> Q1 = Q#amqqueue {
- slave_pids = SPids -- [SPid],
- gm_pids = [T || T = {_, S} <- GMPids,
- S =/= SPid] },
- add_slave(Q1, Self, GM),
- {new, QPid, GMPids}
- end
+ case mnesia:read({rabbit_queue, QName}) of
+ [Q = #amqqueue { pid = QPid, slave_pids = SPids, gm_pids = GMPids }] ->
+ case [Pid || Pid <- [QPid | SPids], node(Pid) =:= Node] of
+ [] ->
+ add_slave(Q, Self, GM),
+ {new, QPid, GMPids};
+ [QPid] ->
+ case rabbit_misc:is_process_alive(QPid) of
+ true -> duplicate_live_master;
+ false -> {stale, QPid}
+ end;
+ [SPid] ->
+ case rabbit_misc:is_process_alive(SPid) of
+ true ->
+ existing;
+ false ->
+ Q1 = Q#amqqueue {
+ slave_pids = SPids -- [SPid],
+ gm_pids = [T || T = {_, S} <- GMPids,
+ S =/= SPid] },
+ add_slave(Q1, Self, GM),
+ {new, QPid, GMPids}
+ end
+ end;
+ [] ->
+ master_recovery_detected
end.
%% Add to the end, so they are in descending order of age, see