Skip to content

Commit c443f82

Browse files
committed
See #7389. Only check tick pid if ts is expired
1 parent 0cc21e6 commit c443f82

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

deps/rabbit/src/rabbit_fifo.erl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,9 @@ tick(Ts, #?MODULE{cfg = #cfg{name = _Name,
894894
resource = QName}} = State) ->
895895
case is_expired(Ts, State) of
896896
true ->
897-
[{aux, {handle_tick, spawn_deleter, [QName]}}];
897+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}];
898898
false ->
899-
[{aux, {handle_tick, handle_tick, [QName, overview(State), all_nodes(State)]}}]
899+
[{aux, {handle_tick, [QName, overview(State), all_nodes(State)]}}]
900900
end.
901901

902902
-spec overview(state()) -> map().
@@ -1029,14 +1029,14 @@ handle_aux(leader, cast, {#return{msg_ids = MsgIds,
10291029
_ ->
10301030
{no_reply, Aux0, Log0}
10311031
end;
1032-
handle_aux(leader, _, {handle_tick, Fun, Args},
1032+
handle_aux(leader, _, {handle_tick, Args},
10331033
#?AUX{tick_pid = Pid} = Aux, Log, _) ->
10341034
NewPid =
1035-
case Pid =:= undefined orelse is_process_alive(Pid) =:= false of
1036-
true ->
1037-
%% No active TICK pid
1038-
spawn(rabbit_quorum_queue, Fun, Args);
1035+
case process_is_alive(Pid) of
10391036
false ->
1037+
%% No active TICK pid
1038+
spawn(rabbit_quorum_queue, handle_tick, Args);
1039+
true ->
10401040
%% Active TICK pid, do nothing
10411041
Pid
10421042
end,
@@ -1163,6 +1163,10 @@ force_eval_gc(Log, #?MODULE{cfg = #cfg{resource = QR}},
11631163
AuxState
11641164
end.
11651165

1166+
process_is_alive(Pid) when is_pid(Pid) ->
1167+
is_process_alive(Pid);
1168+
process_is_alive(_) ->
1169+
false.
11661170
%%% Queries
11671171

11681172
query_messages_ready(State) ->

deps/rabbit/test/rabbit_fifo_SUITE.erl

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ tick_test(C) ->
608608
{S3, {_, _}} = deq(C, 4, Cid2, unsettled, Msg2, S2),
609609
{S4, _, _} = apply(meta(C, 5), rabbit_fifo:make_return(Cid, [MsgId]), S3),
610610

611-
[{aux, {handle_tick, handle_tick,
611+
[{aux, {handle_tick,
612612
[#resource{},
613613
#{config := #{name := ?FUNCTION_NAME},
614614
num_consumers := 1,
@@ -1562,7 +1562,7 @@ purge_nodes_test(C) ->
15621562
{down, EnqPid, noconnection},
15631563
State3),
15641564
?assertMatch(
1565-
[{aux, {handle_tick, handle_tick,
1565+
[{aux, {handle_tick,
15661566
[#resource{}, _Metrics,
15671567
[ThisNode, Node]
15681568
]}}] , rabbit_fifo:tick(1, State4)),
@@ -1578,7 +1578,7 @@ purge_nodes_test(C) ->
15781578
?assertMatch(#rabbit_fifo{consumers = Cons} when map_size(Cons) == 0,
15791579
State),
15801580
?assertMatch(
1581-
[{aux, {handle_tick, handle_tick,
1581+
[{aux, {handle_tick,
15821582
[#resource{}, _Metrics,
15831583
[ThisNode]
15841584
]}}] , rabbit_fifo:tick(1, State)),
@@ -1765,33 +1765,33 @@ queue_ttl_test(C) ->
17651765
expires => 1000},
17661766
S0 = rabbit_fifo:init(Conf),
17671767
Now = 1500,
1768-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S0),
1768+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S0),
17691769
%% this should delete the queue
1770-
[{aux, {handle_tick, spawn_deleter, [QName]}}]
1770+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
17711771
= rabbit_fifo:tick(Now + 1000, S0),
17721772
%% adding a consumer should not ever trigger deletion
17731773
Cid = {<<"cid1">>, self()},
17741774
{S1, _} = check_auto(C, Cid, 1, S0),
1775-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S1),
1776-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S1),
1775+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S1),
1776+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S1),
17771777
%% cancelling the consumer should then
17781778
{S2, _, _} = apply(meta(C, 2, Now),
17791779
rabbit_fifo:make_checkout(Cid, cancel, #{}), S1),
17801780
%% last_active should have been reset when consumer was cancelled
17811781
%% last_active = 2500
1782-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2),
1782+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2),
17831783
%% but now it should be deleted
1784-
[{aux, {handle_tick, spawn_deleter, [QName]}}]
1784+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
17851785
= rabbit_fifo:tick(Now + 2500, S2),
17861786

17871787
%% Same for downs
17881788
{S2D, _, _} = apply(meta(C, 2, Now),
17891789
{down, self(), noconnection}, S1),
17901790
%% last_active should have been reset when consumer was cancelled
17911791
%% last_active = 2500
1792-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2D),
1792+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2D),
17931793
%% but now it should be deleted
1794-
[{aux, {handle_tick, spawn_deleter, [QName]}}]
1794+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
17951795
= rabbit_fifo:tick(Now + 2500, S2D),
17961796

17971797
%% dequeue should set last applied
@@ -1800,9 +1800,9 @@ queue_ttl_test(C) ->
18001800
rabbit_fifo:make_checkout(Cid, {dequeue, unsettled}, #{}),
18011801
S0),
18021802

1803-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S1Deq),
1803+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S1Deq),
18041804
%% but now it should be deleted
1805-
[{aux, {handle_tick, spawn_deleter, [QName]}}]
1805+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
18061806
= rabbit_fifo:tick(Now + 2500, S1Deq),
18071807
%% Enqueue message,
18081808
Msg = rabbit_fifo:make_enqueue(self(), 1, msg1),
@@ -1818,9 +1818,9 @@ queue_ttl_test(C) ->
18181818
{wrap_reply, {dequeue, {MsgId, _}, _}}}] = Fun2([Msg]),
18191819
{E3, _, _} = apply(meta(C, 3, Now + 1000),
18201820
rabbit_fifo:make_settle(Deq, [MsgId]), E2),
1821-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1500, E3),
1821+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1500, E3),
18221822
%% but now it should be deleted
1823-
[{aux, {handle_tick, spawn_deleter, [QName]}}]
1823+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
18241824
= rabbit_fifo:tick(Now + 3000, E3),
18251825
ok.
18261826

@@ -1833,30 +1833,33 @@ queue_ttl_with_single_active_consumer_test(C) ->
18331833
single_active_consumer_on => true},
18341834
S0 = rabbit_fifo:init(Conf),
18351835
Now = 1500,
1836-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S0),
1836+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S0),
18371837
%% this should delete the queue
1838-
[{aux, {handle_tick, spawn_deleter, [QName]}}] = rabbit_fifo:tick(Now + 1000, S0),
1838+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
1839+
= rabbit_fifo:tick(Now + 1000, S0),
18391840
%% adding a consumer should not ever trigger deletion
18401841
Cid = {<<"cid1">>, self()},
18411842
{S1, _} = check_auto(C, Cid, 1, S0),
1842-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S1),
1843-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S1),
1843+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now, S1),
1844+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S1),
18441845
%% cancelling the consumer should then
18451846
{S2, _, _} = apply(meta(C, 2, Now),
18461847
rabbit_fifo:make_checkout(Cid, cancel, #{}), S1),
18471848
%% last_active should have been reset when consumer was cancelled
18481849
%% last_active = 2500
1849-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2),
1850+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2),
18501851
%% but now it should be deleted
1851-
[{aux, {handle_tick, spawn_deleter, [QName]}}] = rabbit_fifo:tick(Now + 2500, S2),
1852+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
1853+
= rabbit_fifo:tick(Now + 2500, S2),
18521854
%% Same for downs
18531855
{S2D, _, _} = apply(meta(C, 2, Now),
18541856
{down, self(), noconnection}, S1),
18551857
%% last_active should have been reset when consumer was cancelled
18561858
%% last_active = 2500
1857-
[{aux, {handle_tick, handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2D),
1859+
[{aux, {handle_tick, [_, _, _]}}] = rabbit_fifo:tick(Now + 1000, S2D),
18581860
%% but now it should be deleted
1859-
[{aux, {handle_tick, spawn_deleter, [QName]}}] = rabbit_fifo:tick(Now + 2500, S2D),
1861+
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}]
1862+
= rabbit_fifo:tick(Now + 2500, S2D),
18601863
ok.
18611864

18621865
query_peek_test(C) ->

0 commit comments

Comments
 (0)