diff options
| author | Emile Joubert <emile@rabbitmq.com> | 2013-08-22 15:44:39 +0100 |
|---|---|---|
| committer | Emile Joubert <emile@rabbitmq.com> | 2013-08-22 15:44:39 +0100 |
| commit | 719e5e176b438a383f7ce472a8c29516ca8f2558 (patch) | |
| tree | cda45abded4c08c58379c5f84dbd5362f8f7db52 | |
| parent | 33d7248feb0be93fea931958d3a9edd65d0f6077 (diff) | |
| download | rabbitmq-server-git-719e5e176b438a383f7ce472a8c29516ca8f2558.tar.gz | |
Solve startup conflict between nodes by restarting slave runtime
| -rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 54ee7129b6..ec6e500f57 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 |
