summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiana Corbacho <diana@rabbitmq.com>2016-09-19 14:13:43 +0100
committerDiana Corbacho <diana@rabbitmq.com>2016-09-19 15:17:18 +0100
commit1cdef63c2fbdc547b725e89ca3efbfed766956d5 (patch)
tree4479d24fd67b4d6bfab921e2d8fa4e231cd61ded /src
parent4e3715591d91a6aac7351aeed8a3fab7de7f438b (diff)
downloadrabbitmq-server-git-1cdef63c2fbdc547b725e89ca3efbfed766956d5.tar.gz
Stop slaves once removed from the amqqueue record by other nodes
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_mirror_queue_slave.erl17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 2cb4455180..4770018f9e 100644
--- a/src/rabbit_mirror_queue_slave.erl
+++ b/src/rabbit_mirror_queue_slave.erl
@@ -256,8 +256,21 @@ handle_cast(go, {not_started, Q} = NotStarted) ->
handle_cast({run_backing_queue, Mod, Fun}, State) ->
noreply(run_backing_queue(Mod, Fun, State));
-handle_cast({gm, Instruction}, State) ->
- handle_process_result(process_instruction(Instruction, State));
+handle_cast({gm, Instruction}, State = #state{q = #amqqueue { name = QName }}) ->
+ case rabbit_amqqueue:lookup(QName) of
+ {ok, #amqqueue{slave_pids = SPids}} ->
+ case lists:member(self(), SPids) of
+ true ->
+ handle_process_result(process_instruction(Instruction, State));
+ false ->
+ %% Potentially a duplicated slave caused by a partial partition,
+ %% will stop as a new slave could start unaware of our presence
+ {stop, shutdown, State}
+ end;
+ {error, not_found} ->
+ %% Would not expect this to happen after fixing #953
+ {stop, shutdown, State}
+ end;
handle_cast({deliver, Delivery = #delivery{sender = Sender, flow = Flow}, true},
State) ->