Skip to content

Commit

Permalink
Avoid using unfortunate terms in more places
Browse files Browse the repository at this point in the history
We have switched all doc guides to use "follower", "mirror" or "secondary"
years ago but some comments and test suites were never updated,
even though their changes would not be breaking.

This transition is a medium-term WIP.

(cherry picked from commit 4ac0e5f)
  • Loading branch information
michaelklishin committed Jun 26, 2020
1 parent 076d243 commit 49dbe42
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion src/rabbit_amqqueue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ wait_for_promoted_or_stopped(Q0) ->
case lists:any(fun(Pid) ->
rabbit_mnesia:is_process_alive(Pid)
end, SPids) of
%% There is a live slave. May be promoted
%% There is a live mirror. May be promoted
true ->
timer:sleep(100),
wait_for_promoted_or_stopped(Q);
Expand Down
6 changes: 3 additions & 3 deletions src/rabbit_mirror_queue_master.erl
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ is_duplicate(Message = #basic_message { id = MsgId },
backing_queue_state = BQS,
confirmed = Confirmed }) ->
%% Here, we need to deal with the possibility that we're about to
%% receive a message that we've already seen when we were a slave
%% receive a message that we've already seen when we were a mirror
%% (we received it via gm). Thus if we do receive such message now
%% via the channel, there may be a confirm waiting to issue for
%% it.
Expand All @@ -478,12 +478,12 @@ is_duplicate(Message = #basic_message { id = MsgId },
%% confirmed some time after that (maybe even after
%% promotion), but before we received the publish from the
%% channel, so couldn't previously know what the
%% msg_seq_no was (and thus confirm as a slave). So we
%% msg_seq_no was (and thus confirm as a mirror). So we
%% need to confirm now. As above, amqqueue_process will
%% have the entry for the msg_id_to_channel mapping added
%% immediately after calling is_duplicate/2.
orelse Disposition =:= discarded ->
%% Message was discarded while we were a slave. Confirm now.
%% Message was discarded while we were a mirror. Confirm now.
%% As above, amqqueue_process will have the entry for the
%% msg_id_to_channel mapping.
{{true, drop}, State #state { seen_status = maps:remove(MsgId, SS),
Expand Down
2 changes: 1 addition & 1 deletion src/rabbit_mirror_queue_slave.erl
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ confirm_sender_death(Pid) ->
Fun =
fun (?MODULE, State = #state { known_senders = KS,
gm = GM }) ->
%% We're running still as a slave
%% We're running still as a mirror
%%
%% See comment in local_sender_death/2; we might have
%% received a sender_death in the meanwhile so check
Expand Down
36 changes: 18 additions & 18 deletions test/clustering_management_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ groups() ->
persistent_cluster_id
]},
{cluster_size_4, [], [
forget_promotes_offline_slave
forget_promotes_offline_follower
]}
]}
].
Expand Down Expand Up @@ -378,13 +378,13 @@ forget_offline_removes_things(Config) ->
passive = true})),
ok.

forget_promotes_offline_slave(Config) ->
forget_promotes_offline_follower(Config) ->
[A, B, C, D] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
QName = <<"mirrored-queue">>,
declare(ACh, QName),
set_ha_policy(Config, QName, A, [B, C]),
set_ha_policy(Config, QName, A, [C, D]), %% Test add and remove from recoverable_slaves
set_ha_policy(Config, QName, A, [C, D]), %% Test add and remove from recoverable_mirrors

%% Publish and confirm
amqp_channel:call(ACh, #'confirm.select'{}),
Expand Down Expand Up @@ -426,41 +426,41 @@ set_ha_policy(Config, QName, Master, Slaves) ->
Nodes = [list_to_binary(atom_to_list(N)) || N <- [Master | Slaves]],
HaPolicy = {<<"nodes">>, Nodes},
rabbit_ct_broker_helpers:set_ha_policy(Config, Master, QName, HaPolicy),
await_slaves(QName, Master, Slaves).
await_followers(QName, Master, Slaves).

await_slaves(QName, Master, Slaves) ->
await_slaves_0(QName, Master, Slaves, 10).
await_followers(QName, Master, Slaves) ->
await_followers_0(QName, Master, Slaves, 10).

await_slaves_0(QName, Master, Slaves0, Tries) ->
{ok, Queue} = await_slaves_lookup_queue(QName, Master),
await_followers_0(QName, Master, Slaves0, Tries) ->
{ok, Queue} = await_followers_lookup_queue(QName, Master),
SPids = amqqueue:get_slave_pids(Queue),
ActMaster = amqqueue:qnode(Queue),
ActSlaves = lists:usort([node(P) || P <- SPids]),
Slaves1 = lists:usort(Slaves0),
await_slaves_1(QName, ActMaster, ActSlaves, Master, Slaves1, Tries).
await_followers_1(QName, ActMaster, ActSlaves, Master, Slaves1, Tries).

await_slaves_1(QName, _ActMaster, _ActSlaves, _Master, _Slaves, 0) ->
error({timeout_waiting_for_slaves, QName});
await_slaves_1(QName, ActMaster, ActSlaves, Master, Slaves, Tries) ->
await_followers_1(QName, _ActMaster, _ActSlaves, _Master, _Slaves, 0) ->
error({timeout_waiting_for_followers, QName});
await_followers_1(QName, ActMaster, ActSlaves, Master, Slaves, Tries) ->
case {Master, Slaves} of
{ActMaster, ActSlaves} ->
ok;
_ ->
timer:sleep(250),
await_slaves_0(QName, Master, Slaves, Tries - 1)
await_followers_0(QName, Master, Slaves, Tries - 1)
end.

await_slaves_lookup_queue(QName, Master) ->
await_slaves_lookup_queue(QName, Master, 10).
await_followers_lookup_queue(QName, Master) ->
await_followers_lookup_queue(QName, Master, 10).

await_slaves_lookup_queue(QName, _Master, 0) ->
await_followers_lookup_queue(QName, _Master, 0) ->
error({timeout_looking_up_queue, QName});
await_slaves_lookup_queue(QName, Master, Tries) ->
await_followers_lookup_queue(QName, Master, Tries) ->
RpcArgs = [rabbit_misc:r(<<"/">>, queue, QName)],
case rpc:call(Master, rabbit_amqqueue, lookup, RpcArgs) of
{error, not_found} ->
timer:sleep(250),
await_slaves_lookup_queue(QName, Master, Tries - 1);
await_followers_lookup_queue(QName, Master, Tries - 1);
{ok, Q} ->
{ok, Q}
end.
Expand Down
10 changes: 5 additions & 5 deletions test/crashing_queues_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ crashing_mirrored(Config) ->
#'queue.declare'{queue = QName, durable = true}),
ok.

test_queue_failure(Node, Ch, RaceConn, MsgCount, SlaveCount, Decl) ->
test_queue_failure(Node, Ch, RaceConn, MsgCount, FollowerCount, Decl) ->
#'queue.declare_ok'{queue = QName} = amqp_channel:call(Ch, Decl),
try
publish(Ch, QName, transient),
publish(Ch, QName, durable),
Racer = spawn_declare_racer(RaceConn, Decl),
kill_queue(Node, QName),
assert_message_count(MsgCount, Ch, QName),
assert_slave_count(SlaveCount, Node, QName),
assert_follower_count(FollowerCount, Node, QName),
stop_declare_racer(Racer)
after
amqp_channel:call(Ch, #'queue.delete'{queue = QName})
Expand Down Expand Up @@ -258,7 +258,7 @@ assert_message_count(Count, Ch, QName) ->
amqp_channel:call(Ch, #'queue.declare'{queue = QName,
passive = true}).

assert_slave_count(Count, Node, QName) ->
assert_follower_count(Count, Node, QName) ->
Q = lookup(Node, QName),
[{_, Pids}] = rpc:call(Node, rabbit_amqqueue, info, [Q, [slave_pids]]),
RealCount = case Pids of
Expand All @@ -270,7 +270,7 @@ assert_slave_count(Count, Node, QName) ->
ok;
_ when RealCount < Count ->
timer:sleep(10),
assert_slave_count(Count, Node, QName);
assert_follower_count(Count, Node, QName);
_ ->
exit({too_many_slaves, Count, RealCount})
exit({too_many_replicas, Count, RealCount})
end.
Loading

0 comments on commit 49dbe42

Please sign in to comment.