summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2015-02-02 11:26:21 +0000
committerSimon MacMullen <simon@rabbitmq.com>2015-02-02 11:26:21 +0000
commit80548e1b1059692dd6584b38e7afbacbecb4cbdd (patch)
treeacc7fea079e6700d0bbfa2c983c2e3f4bc851033
parentc909a478212e7868adf1f5639fad200cb2b9700d (diff)
parent30727dc3c10972f34c2a034e7c0e6db77f175943 (diff)
downloadrabbitmq-server-git-80548e1b1059692dd6584b38e7afbacbecb4cbdd.tar.gz
stable to default
-rw-r--r--src/rabbit_mirror_queue_coordinator.erl11
-rw-r--r--src/rabbit_mirror_queue_slave.erl3
2 files changed, 13 insertions, 1 deletions
diff --git a/src/rabbit_mirror_queue_coordinator.erl b/src/rabbit_mirror_queue_coordinator.erl
index a8f5e74899..38273e1c28 100644
--- a/src/rabbit_mirror_queue_coordinator.erl
+++ b/src/rabbit_mirror_queue_coordinator.erl
@@ -19,7 +19,7 @@
-export([start_link/4, get_gm/1, ensure_monitoring/2]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
- code_change/3]).
+ code_change/3, handle_pre_hibernate/1]).
-export([joined/2, members_changed/3, handle_msg/3, handle_terminate/2]).
@@ -390,6 +390,15 @@ terminate(_Reason, #state{}) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
+handle_pre_hibernate(State = #state { gm = GM }) ->
+ %% Since GM notifications of deaths are lazy we might not get a
+ %% timely notification of slave death if policy changes when
+ %% everything is idle. So cause some activity just before we
+ %% sleep. This won't cause us to go into perpetual motion as the
+ %% heartbeat does not wake up coordinator or slaves.
+ gm:broadcast(GM, hibernate_heartbeat),
+ {hibernate, State}.
+
%% ---------------------------------------------------------------------------
%% GM
%% ---------------------------------------------------------------------------
diff --git a/src/rabbit_mirror_queue_slave.erl b/src/rabbit_mirror_queue_slave.erl
index 45167706b4..96515f5c35 100644
--- a/src/rabbit_mirror_queue_slave.erl
+++ b/src/rabbit_mirror_queue_slave.erl
@@ -428,6 +428,9 @@ members_changed([ SPid], _Births, Deaths) ->
{promote, CPid} -> {become, rabbit_mirror_queue_coordinator, [CPid]}
end.
+handle_msg([_SPid], _From, hibernate_heartbeat) ->
+ %% See rabbit_mirror_queue_coordinator:handle_pre_hibernate/1
+ ok;
handle_msg([_SPid], _From, request_depth) ->
%% This is only of value to the master
ok;