summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_amqqueue_process.erl2
-rw-r--r--src/rabbit_mirror_queue_coordinator.erl11
-rw-r--r--src/rabbit_mirror_queue_slave.erl3
3 files changed, 14 insertions, 2 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index a18df22522..16ead64af9 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -153,7 +153,6 @@ init_it2(Recover, From, State = #q{q = Q,
#amqqueue{} = Q1 ->
case matches(Recover, Q, Q1) of
true ->
- send_reply(From, {new, Q}),
ok = file_handle_cache:register_callback(
rabbit_amqqueue, set_maximum_since_use, [self()]),
ok = rabbit_memory_monitor:register(
@@ -161,6 +160,7 @@ init_it2(Recover, From, State = #q{q = Q,
set_ram_duration_target, [self()]}),
BQ = backing_queue_module(Q1),
BQS = bq_init(BQ, Q, TermsOrNew),
+ send_reply(From, {new, Q}),
recovery_barrier(Barrier),
State1 = process_args_policy(
State#q{backing_queue = BQ,
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;