diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_mirror_queue_coordinator.erl | 11 | ||||
| -rw-r--r-- | src/rabbit_mirror_queue_slave.erl | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/rabbit_mirror_queue_coordinator.erl b/src/rabbit_mirror_queue_coordinator.erl index 3d4605280f..d328488298 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]). @@ -389,6 +389,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 92e1cc2736..c64e35599c 100644 --- a/src/rabbit_mirror_queue_slave.erl +++ b/src/rabbit_mirror_queue_slave.erl @@ -421,6 +421,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; |
