diff options
-rw-r--r-- | src/rabbit_mirror_queue_master.erl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/rabbit_mirror_queue_master.erl b/src/rabbit_mirror_queue_master.erl index f1b1a8a5..aa1e1ab9 100644 --- a/src/rabbit_mirror_queue_master.erl +++ b/src/rabbit_mirror_queue_master.erl @@ -201,9 +201,15 @@ delete_and_terminate(Reason, State = #state { backing_queue = BQ, stop_all_slaves(Reason, #state{name = QName, gm = GM}) -> {ok, #amqqueue{slave_pids = SPids}} = rabbit_amqqueue:lookup(QName), - MRefs = [erlang:monitor(process, Pid) || Pid <- [GM | SPids]], + PidsMRefs = [{Pid, erlang:monitor(process, Pid)} || Pid <- [GM | SPids]], ok = gm:broadcast(GM, {delete_and_terminate, Reason}), - [receive {'DOWN', MRef, process, _Pid, _Info} -> ok end || MRef <- MRefs], + %% It's possible that we could be partitioned from some slaves + %% between the lookup and the broadcast, in which case we could + %% monitor them but they would not have received the GM + %% message. So only wait for slaves which are still + %% not-partitioned. + [receive {'DOWN', MRef, process, _Pid, _Info} -> ok end + || {Pid, MRef} <- PidsMRefs, rabbit_mnesia:on_running_node(Pid)], %% Normally when we remove a slave another slave or master will %% notice and update Mnesia. But we just removed them all, and %% have stopped listening ourselves. So manually clean up. |