summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriele Santomaggio <gabriele.santomaggio@erlang-solutions.com>2016-05-27 11:58:32 +0200
committerDiana Corbacho <diana.corbacho@erlang-solutions.com>2016-05-27 16:46:04 +0100
commit38be6a77d2f8322801a61e2222c22fc665990cf0 (patch)
treefdcd5c2f41e543dedb9f3b432444f16ecb83e164 /src
parent0ee7b1580ed683a924434cf56250d250123b70a0 (diff)
downloadrabbitmq-server-git-38be6a77d2f8322801a61e2222c22fc665990cf0.tar.gz
Update policy version on set_policy and use it on update_mirroring
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_amqqueue_process.erl17
-rw-r--r--src/rabbit_policy.erl4
2 files changed, 14 insertions, 7 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index bf7484557d..59c9d7826e 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -703,7 +703,7 @@ handle_ch_down(DownPid, State = #q{consumers = Consumers,
exclusive_consumer = Holder1},
notify_decorators(State2),
case should_auto_delete(State2) of
- true ->
+ true ->
log_auto_delete(
io_lib:format(
"because all of its consumers (~p) were on a channel that was closed",
@@ -1072,11 +1072,11 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From,
notify_decorators(State1),
case should_auto_delete(State1) of
false -> reply(ok, ensure_expiry_timer(State1));
- true ->
+ true ->
log_auto_delete(
io_lib:format(
"because its last consumer with tag '~s' was cancelled",
- [ConsumerTag]),
+ [ConsumerTag]),
State),
stop(ok, State1)
end
@@ -1375,9 +1375,14 @@ log_auto_delete(Reason, #q{ q = #amqqueue{ name = Resource } }) ->
Reason,
[QName, VHost]).
-needs_update_mirroring(_Q, _Version) ->
- %% hook here GaS changes on the policy
- true.
+needs_update_mirroring(Q, Version) ->
+ {ok, UpQ} = rabbit_amqqueue:lookup(Q#amqqueue.name),
+ DBVersion = UpQ#amqqueue.policy_version,
+ case DBVersion > Version of
+ true -> {rabbit_policy:get(<<"ha-mode">>, UpQ), DBVersion};
+ false -> false
+ end.
+
update_mirroring(Policy, State = #q{backing_queue = BQ}) ->
case update_to(Policy, BQ) of
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index eb8cf63327..a9caadf972 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -276,7 +276,9 @@ update_queue(Q = #amqqueue{name = QName, policy = OldPolicy}, Policies) ->
NewPolicy -> case rabbit_amqqueue:update(
QName, fun(Q1) ->
rabbit_queue_decorator:set(
- Q1#amqqueue{policy = NewPolicy})
+ Q1#amqqueue{policy = NewPolicy,
+ policy_version =
+ Q1#amqqueue.policy_version + 1 })
end) of
#amqqueue{} = Q1 -> {Q, Q1};
not_found -> {Q, Q }