Skip to content

Commit 7cb4835

Browse files
Merge branch 'stable' into rabbitmq-server-960
2 parents ed1ef0a + e0866b7 commit 7cb4835

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

src/gm.erl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,11 +1175,20 @@ record_new_member_in_group(NewMember, Left, GroupName, TxnFun) ->
11751175
try
11761176
Group = #gm_group { members = Members, version = Ver } =
11771177
check_membership(Left, read_group(GroupName)),
1178-
{Prefix, [Left | Suffix]} =
1179-
lists:splitwith(fun (M) -> M =/= Left end, Members),
1180-
write_group(Group #gm_group {
1181-
members = Prefix ++ [Left, NewMember | Suffix],
1182-
version = Ver + 1 })
1178+
case lists:member(NewMember, Members) of
1179+
true ->
1180+
%% This avois duplicates during partial partitions,
1181+
%% as inconsistent views might happen during them
1182+
rabbit_log:warning("(~p) GM avoiding duplicate of ~p",
1183+
[self(), NewMember]),
1184+
Group;
1185+
false ->
1186+
{Prefix, [Left | Suffix]} =
1187+
lists:splitwith(fun (M) -> M =/= Left end, Members),
1188+
write_group(Group #gm_group {
1189+
members = Prefix ++ [Left, NewMember | Suffix],
1190+
version = Ver + 1 })
1191+
end
11831192
catch
11841193
lost_membership ->
11851194
%% The transaction must not be abruptly crashed, but

src/rabbit_amqqueue_process.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,13 @@ handle_cast(policy_changed, State = #q{q = #amqqueue{name = Name}}) ->
13001300
%% This also has the side effect of waking us up so we emit a
13011301
%% stats event - so event consumers see the changed policy.
13021302
{ok, Q} = rabbit_amqqueue:lookup(Name),
1303-
noreply(process_args_policy(State#q{q = Q})).
1303+
noreply(process_args_policy(State#q{q = Q}));
1304+
1305+
handle_cast({sync_start, _, _}, State = #q{q = #amqqueue{name = Name}}) ->
1306+
%% Only a slave should receive this, it means we are a duplicated master
1307+
rabbit_mirror_queue_misc:log_warning(
1308+
Name, "Stopping after receiving sync_start from another master", []),
1309+
stop(State).
13041310

13051311
handle_info({maybe_expire, Vsn}, State = #q{args_policy_version = Vsn}) ->
13061312
case is_unused(State) of

src/rabbit_mirror_queue_slave.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ handle_cast({set_ram_duration_target, Duration},
314314
State = #state { backing_queue = BQ,
315315
backing_queue_state = BQS }) ->
316316
BQS1 = BQ:set_ram_duration_target(Duration, BQS),
317-
noreply(State #state { backing_queue_state = BQS1 }).
317+
noreply(State #state { backing_queue_state = BQS1 });
318+
319+
handle_cast(policy_changed, State) ->
320+
%% During partial partitions, we might end up receiving messages expected by a master
321+
%% Ignore them
322+
noreply(State).
318323

319324
handle_info(update_ram_duration, State = #state{backing_queue = BQ,
320325
backing_queue_state = BQS}) ->

0 commit comments

Comments
 (0)