Skip to content

Commit 21b9eb5

Browse files
kjnilssonlukebakken
authored andcommitted
Fix quorum queue queue federation bugs
Quorum queues would due to a misunderstanding whilst porting queue decorators from classic queues calculate the wrong maximum consumer priority leading to strange behaviour when using queue federation. Also notify decorators on startup. In this case we had to do this when a member becomes leader which isn't always at startup so will have to rely on the mirroried supervisor to ensure we don't start multiple federation links.
1 parent f83ed85 commit 21b9eb5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

deps/rabbit/src/rabbit_fifo.erl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,10 @@ state_enter0(leader, #?MODULE{consumers = Cons,
861861
Mons = [{monitor, process, P} || P <- Pids],
862862
Nots = [{send_msg, P, leader_change, ra_event} || P <- Pids],
863863
NodeMons = lists:usort([{monitor, node, node(P)} || P <- Pids]),
864-
FHReservation = [{mod_call, rabbit_quorum_queue, file_handle_leader_reservation, [Resource]}],
865-
Effects = TimerEffs ++ Mons ++ Nots ++ NodeMons ++ FHReservation,
864+
FHReservation = [{mod_call, rabbit_quorum_queue,
865+
file_handle_leader_reservation, [Resource]}],
866+
NotifyDecs = notify_decorators_startup(Resource),
867+
Effects = TimerEffs ++ Mons ++ Nots ++ NodeMons ++ FHReservation ++ [NotifyDecs],
866868
case BLH of
867869
undefined ->
868870
Effects;
@@ -1299,9 +1301,8 @@ query_notify_decorators_info(#?MODULE{consumers = Consumers} = State) ->
12991301
MaxActivePriority = maps:fold(
13001302
fun(_, #consumer{credit = C,
13011303
status = up,
1302-
cfg = #consumer_cfg{priority = P0}},
1304+
cfg = #consumer_cfg{priority = P}},
13031305
MaxP) when C > 0 ->
1304-
P = -P0,
13051306
case MaxP of
13061307
empty -> P;
13071308
MaxP when MaxP > P -> MaxP;
@@ -2477,6 +2478,10 @@ notify_decorators_effect(QName, MaxActivePriority, IsEmpty) ->
24772478
{mod_call, rabbit_quorum_queue, spawn_notify_decorators,
24782479
[QName, consumer_state_changed, [MaxActivePriority, IsEmpty]]}.
24792480

2481+
notify_decorators_startup(QName) ->
2482+
{mod_call, rabbit_quorum_queue, spawn_notify_decorators,
2483+
[QName, startup, []]}.
2484+
24802485
convert(To, To, State) ->
24812486
State;
24822487
convert(0, To, State) ->

0 commit comments

Comments
 (0)