summaryrefslogtreecommitdiff
path: root/src/rabbit_mirror_queue_misc.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-11-11 14:08:08 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-11-11 14:08:08 +0000
commite54434c75490ff3995fb97afb5fafd1541ec81f7 (patch)
treec2779a4bef437a45dbe1eec695bdaf1c18be7f40 /src/rabbit_mirror_queue_misc.erl
parent3de3589691eef4335d941915d4e08190b4f75ec6 (diff)
downloadrabbitmq-server-e54434c75490ff3995fb97afb5fafd1541ec81f7.tar.gz
Port the deadlock-breaking code from bug 25852.
Diffstat (limited to 'src/rabbit_mirror_queue_misc.erl')
-rw-r--r--src/rabbit_mirror_queue_misc.erl34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/rabbit_mirror_queue_misc.erl b/src/rabbit_mirror_queue_misc.erl
index 8ad7c62f..47a44278 100644
--- a/src/rabbit_mirror_queue_misc.erl
+++ b/src/rabbit_mirror_queue_misc.erl
@@ -19,7 +19,8 @@
-export([remove_from_queue/3, on_node_up/0, add_mirrors/2, add_mirror/2,
report_deaths/4, store_updated_slaves/1, suggested_queue_nodes/1,
- is_mirrored/1, update_mirrors/2, validate_policy/1]).
+ is_mirrored/1, update_mirrors/2, validate_policy/1,
+ maybe_auto_sync/1]).
%% for testing only
-export([module/1]).
@@ -94,10 +95,14 @@ remove_from_queue(QueueName, Self, LiveGMPids) ->
%% Either master hasn't changed, so
%% we're ok to update mnesia; or we have
%% become the master.
- store_updated_slaves(
- Q #amqqueue { pid = QPid1,
+ Q1 = Q#amqqueue{pid = QPid1,
slave_pids = SPids1,
- gm_pids = GMPids1 }),
+ gm_pids = GMPids1},
+ store_updated_slaves(Q1),
+ %% If we add and remove nodes at the same time
+ %% it's possible we need to sync after removing
+ %% the master. Let's check.
+ maybe_auto_sync(Q1),
{ok, QPid1, [QPid | SPids] -- Alive};
_ ->
%% Master has changed, and we're not it,
@@ -179,26 +184,15 @@ add_mirror(QName, MirrorNode) ->
end
end).
-start_child(Name, MirrorNode, Q) ->
+start_child(_Name, MirrorNode, Q) ->
+ %% TODO re-add some log stuff here.
case rabbit_misc:with_exit_handler(
- rabbit_misc:const({ok, down}),
+ rabbit_misc:const(down),
fun () ->
rabbit_mirror_queue_slave_sup:start_child(MirrorNode, [Q])
end) of
- {ok, SPid} when is_pid(SPid) ->
- maybe_auto_sync(Q),
- rabbit_log:info("Adding mirror of ~s on node ~p: ~p~n",
- [rabbit_misc:rs(Name), MirrorNode, SPid]),
- {ok, started};
- {error, {{stale_master_pid, StalePid}, _}} ->
- rabbit_log:warning("Detected stale HA master while adding "
- "mirror of ~s on node ~p: ~p~n",
- [rabbit_misc:rs(Name), MirrorNode, StalePid]),
- {ok, stale_master};
- {error, {{duplicate_live_master, _}=Err, _}} ->
- Err;
- Other ->
- Other
+ {ok, SPid} -> rabbit_mirror_queue_slave:go(SPid);
+ _ -> ok
end.
report_deaths(_MirrorPid, _IsMaster, _QueueName, []) ->