From 28062ca1238cd9b32a105494b457741c704fbf86 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Tue, 9 Oct 2012 16:05:35 +0100 Subject: Ignore process_death, explain why. --- src/rabbit_mirror_queue_slave.erl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 307f2b4f..36f9766d 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -257,8 +257,8 @@ handle_info(timeout, State) -> noreply(backing_queue_timeout(State)); handle_info({'DOWN', _MonitorRef, process, MPid, _Reason}, - State = #state { gm = GM, master_pid = MPid }) -> - ok = gm:broadcast(GM, {process_death, MPid}), + State = #state { gm = GM, master_pid = MPid }) -> + ok = gm:broadcast(GM, process_death), noreply(State); handle_info({'DOWN', _MonitorRef, process, ChPid, _Reason}, State) -> @@ -353,8 +353,15 @@ handle_msg([_SPid], _From, request_depth) -> handle_msg([_SPid], _From, {ensure_monitoring, _Pid}) -> %% This is only of value to the master ok; -handle_msg([SPid], _From, {process_death, Pid}) -> - inform_deaths(SPid, [Pid]); +handle_msg([_SPid], _From, process_death) -> + %% Since GM is by nature lazy we need to make sure there is some + %% traffic when a master dies, to make sure we get informed of the + %% death. That's all process_death does, create some traffic. We + %% must not take any notice of the master death here since it + %% comes without ordering guarantees - there could still be + %% messages from the master we have yet to receive. When we get + %% members_changed, then there will be no more messages. + ok; handle_msg([CPid], _From, {delete_and_terminate, _Reason} = Msg) -> ok = gen_server2:cast(CPid, {gm, Msg}), {stop, {shutdown, ring_shutdown}}; -- cgit v1.2.1 From 6520300813d6394733c8c6a5ee9e7145eed908b4 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Tue, 9 Oct 2012 16:06:39 +0100 Subject: Remove this master_changed nonsense. --- src/rabbit_mirror_queue_coordinator.erl | 2 -- src/rabbit_mirror_queue_slave.erl | 11 ----------- 2 files changed, 13 deletions(-) diff --git a/src/rabbit_mirror_queue_coordinator.erl b/src/rabbit_mirror_queue_coordinator.erl index 40359da3..4d8b6ade 100644 --- a/src/rabbit_mirror_queue_coordinator.erl +++ b/src/rabbit_mirror_queue_coordinator.erl @@ -398,8 +398,6 @@ members_changed([_CPid], _Births, []) -> members_changed([CPid], _Births, Deaths) -> ok = gen_server2:cast(CPid, {gm_deaths, Deaths}). -handle_msg([_CPid], _From, master_changed) -> - ok; handle_msg([CPid], _From, request_depth = Msg) -> ok = gen_server2:cast(CPid, Msg); handle_msg([CPid], _From, {ensure_monitoring, _Pids} = Msg) -> diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 36f9766d..60d7ad0c 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -201,12 +201,6 @@ handle_call({gm_deaths, Deaths}, From, %% branch, see last clause in remove_from_queue/2 [] = ExtraNodes, erlang:monitor(process, Pid), - %% GM is lazy. So we know of the death of the - %% slave since it is a neighbour of ours, but - %% until a message is sent, not all members will - %% know. That might include the new master. So - %% broadcast a no-op message to wake everyone up. - ok = gm:broadcast(GM, master_changed), noreply(State #state { master_pid = Pid }) end end; @@ -345,8 +339,6 @@ joined([SPid], _Members) -> SPid ! {joined, self()}, ok. members_changed([_SPid], _Births, []) -> ok; members_changed([ SPid], _Births, Deaths) -> inform_deaths(SPid, Deaths). -handle_msg([_SPid], _From, master_changed) -> - ok; handle_msg([_SPid], _From, request_depth) -> %% This is only of value to the master ok; @@ -461,9 +453,6 @@ promote_me(From, #state { q = Q = #amqqueue { name = QName }, rabbit_mirror_queue_master:depth_fun()), true = unlink(GM), gen_server2:reply(From, {promote, CPid}), - %% TODO this has been in here since the beginning, but it's not - %% obvious if it is needed. Investigate... - ok = gm:confirmed_broadcast(GM, master_changed), %% Everything that we're monitoring, we need to ensure our new %% coordinator is monitoring. -- cgit v1.2.1 From 81cc69afc8a2b408ba9dbabbc1ecf3776fc12739 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Tue, 9 Oct 2012 16:46:52 +0100 Subject: Unused var. --- src/rabbit_mirror_queue_slave.erl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl index 60d7ad0c..53e61e2d 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -173,7 +173,6 @@ handle_call({deliver, Delivery, true}, From, State) -> handle_call({gm_deaths, Deaths}, From, State = #state { q = #amqqueue { name = QueueName }, - gm = GM, master_pid = MPid }) -> %% The GM has told us about deaths, which means we're not going to %% receive any more messages from GM -- cgit v1.2.1