Skip to content

Commit 32e9369

Browse files
committed
Remove rabbit_variable_queue:fold/3
It was only used by CMQs and they have been removed a while back.
1 parent 892bbee commit 32e9369

File tree

3 files changed

+3
-139
lines changed

3 files changed

+3
-139
lines changed

deps/rabbit/src/rabbit_priority_queue.erl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
purge/1, purge_acks/1,
3030
publish/5, publish_delivered/4, discard/3, drain_confirmed/1,
3131
dropwhile/2, fetchwhile/4, fetch/2, drop/2, ack/2, requeue/2,
32-
ackfold/4, fold/3, len/1, is_empty/1, depth/1,
32+
ackfold/4, len/1, is_empty/1, depth/1,
3333
update_rates/1, needs_timeout/1, timeout/1,
3434
handle_pre_hibernate/1, resume/1, msg_rates/1,
3535
info/2, invoke/3, is_duplicate/2, set_queue_mode/2,
@@ -302,11 +302,6 @@ ackfold(MsgFun, Acc, State = #state{bq = BQ}, AckTags) ->
302302
ackfold(MsgFun, Acc, State = #passthrough{bq = BQ, bqs = BQS}, AckTags) ->
303303
?passthrough2(ackfold(MsgFun, Acc, BQS, AckTags)).
304304

305-
fold(Fun, Acc, State = #state{bq = BQ}) ->
306-
fold2(fun (_P, BQSN, AccN) -> BQ:fold(Fun, AccN, BQSN) end, Acc, State);
307-
fold(Fun, Acc, State = #passthrough{bq = BQ, bqs = BQS}) ->
308-
?passthrough2(fold(Fun, Acc, BQS)).
309-
310305
len(#state{bq = BQ, bqss = BQSs}) ->
311306
add0(fun (_P, BQSN) -> BQ:len(BQSN) end, BQSs);
312307
len(#passthrough{bq = BQ, bqs = BQS}) ->

deps/rabbit/src/rabbit_variable_queue.erl

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
publish/5, publish_delivered/4,
1313
discard/3, drain_confirmed/1,
1414
dropwhile/2, fetchwhile/4, fetch/2, drop/2, ack/2, requeue/2,
15-
ackfold/4, fold/3, len/1, is_empty/1, depth/1,
15+
ackfold/4, len/1, is_empty/1, depth/1,
1616
update_rates/1, needs_timeout/1, timeout/1,
1717
handle_pre_hibernate/1, resume/1, msg_rates/1,
1818
info/2, invoke/3, is_duplicate/2, set_queue_mode/2,
@@ -649,14 +649,6 @@ ackfold(MsgFun, Acc, State, AckTags) ->
649649
end, {Acc, State}, AckTags),
650650
{AccN, a(StateN)}.
651651

652-
%% @todo I think this is never used. Was CMQ.
653-
fold(Fun, Acc, State = #vqstate{index_state = IndexState}) ->
654-
{Its, IndexState1} = lists:foldl(fun inext/2, {[], IndexState},
655-
[msg_iterator(State),
656-
disk_ack_iterator(State),
657-
ram_ack_iterator(State)]),
658-
ifold(Fun, Acc, Its, State#vqstate{index_state = IndexState1}).
659-
660652
len(#vqstate { len = Len }) -> Len.
661653

662654
is_empty(State) -> 0 == len(State).
@@ -1985,89 +1977,6 @@ msg_from_pending_ack(SeqId, State) ->
19851977
delta_limit(?BLANK_DELTA_PATTERN(_)) -> undefined;
19861978
delta_limit(#delta { start_seq_id = StartSeqId }) -> StartSeqId.
19871979

1988-
%%----------------------------------------------------------------------------
1989-
%% Iterator
1990-
%%----------------------------------------------------------------------------
1991-
1992-
ram_ack_iterator(State) ->
1993-
{ack, maps:iterator(State#vqstate.ram_pending_ack)}.
1994-
1995-
disk_ack_iterator(State) ->
1996-
{ack, maps:iterator(State#vqstate.disk_pending_ack)}.
1997-
1998-
msg_iterator(State) -> istate(start, State).
1999-
2000-
istate(start, State) -> {q3, State#vqstate.q3, State};
2001-
istate(q3, State) -> {delta, State#vqstate.delta, State};
2002-
istate(delta, _State) -> done.
2003-
2004-
next({ack, It}, IndexState) ->
2005-
case maps:next(It) of
2006-
none -> {empty, IndexState};
2007-
{_SeqId, MsgStatus, It1} -> Next = {ack, It1},
2008-
{value, MsgStatus, true, Next, IndexState}
2009-
end;
2010-
next(done, IndexState) -> {empty, IndexState};
2011-
next({delta, #delta{start_seq_id = SeqId,
2012-
end_seq_id = SeqId}, State}, IndexState) ->
2013-
next(istate(delta, State), IndexState);
2014-
next({delta, #delta{start_seq_id = SeqId,
2015-
end_seq_id = SeqIdEnd} = Delta, State}, IndexState) ->
2016-
SeqIdB = rabbit_classic_queue_index_v2:next_segment_boundary(SeqId),
2017-
%% It may make sense to limit this based on rate. But this
2018-
%% is not called outside of CMQs so I will leave it alone
2019-
%% for the time being.
2020-
SeqId1 = lists:min([SeqIdB,
2021-
%% We must limit the number of messages read at once
2022-
%% otherwise the queue will attempt to read up to segment_entry_count()
2023-
%% messages from the index each time. The value
2024-
%% chosen here is arbitrary.
2025-
SeqId + 2048,
2026-
SeqIdEnd]),
2027-
{List, IndexState1} = rabbit_classic_queue_index_v2:read(SeqId, SeqId1, IndexState),
2028-
next({delta, Delta#delta{start_seq_id = SeqId1}, List, State}, IndexState1);
2029-
next({delta, Delta, [], State}, IndexState) ->
2030-
next({delta, Delta, State}, IndexState);
2031-
next({delta, Delta, [{_, SeqId, _, _, _} = M | Rest], State}, IndexState) ->
2032-
case is_msg_in_pending_acks(SeqId, State) of
2033-
false -> Next = {delta, Delta, Rest, State},
2034-
{value, beta_msg_status(M), false, Next, IndexState};
2035-
true -> next({delta, Delta, Rest, State}, IndexState)
2036-
end;
2037-
next({Key, Q, State}, IndexState) ->
2038-
case ?QUEUE:out(Q) of
2039-
{empty, _Q} -> next(istate(Key, State), IndexState);
2040-
{{value, MsgStatus}, QN} -> Next = {Key, QN, State},
2041-
{value, MsgStatus, false, Next, IndexState}
2042-
end.
2043-
2044-
inext(It, {Its, IndexState}) ->
2045-
case next(It, IndexState) of
2046-
{empty, IndexState1} ->
2047-
{Its, IndexState1};
2048-
{value, MsgStatus1, Unacked, It1, IndexState1} ->
2049-
{[{MsgStatus1, Unacked, It1} | Its], IndexState1}
2050-
end.
2051-
2052-
ifold(_Fun, Acc, [], State0) ->
2053-
{Acc, State0};
2054-
ifold(Fun, Acc, Its0, State0) ->
2055-
[{MsgStatus, Unacked, It} | Rest] =
2056-
lists:sort(fun ({#msg_status{seq_id = SeqId1}, _, _},
2057-
{#msg_status{seq_id = SeqId2}, _, _}) ->
2058-
SeqId1 =< SeqId2
2059-
end, Its0),
2060-
{Msg, State1} = read_msg(MsgStatus, State0),
2061-
case Fun(Msg, MsgStatus#msg_status.msg_props, Unacked, Acc) of
2062-
{stop, Acc1} ->
2063-
{Acc1, State1};
2064-
{cont, Acc1} ->
2065-
IndexState0 = State1#vqstate.index_state,
2066-
{Its1, IndexState1} = inext(It, {Rest, IndexState0}),
2067-
State2 = State1#vqstate{index_state = IndexState1},
2068-
ifold(Fun, Acc1, Its1, State2)
2069-
end.
2070-
20711980
%%----------------------------------------------------------------------------
20721981
%% Phase changes
20731982
%%----------------------------------------------------------------------------

deps/rabbit/test/backing_queue_SUITE.erl

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
variable_queue_ack_limiting,
3434
variable_queue_purge,
3535
variable_queue_requeue,
36-
variable_queue_requeue_ram_beta,
37-
variable_queue_fold
36+
variable_queue_requeue_ram_beta
3837
]).
3938

4039
-define(BACKING_QUEUE_TESTCASES, [
@@ -162,15 +161,9 @@ orelse Group =:= backing_queue_embed_limit_1024 ->
162161
end_per_group1(_, Config) ->
163162
Config.
164163

165-
init_per_testcase(Testcase, Config) when Testcase == variable_queue_requeue;
166-
Testcase == variable_queue_fold ->
167-
rabbit_ct_helpers:testcase_started(Config, Testcase);
168164
init_per_testcase(Testcase, Config) ->
169165
rabbit_ct_helpers:testcase_started(Config, Testcase).
170166

171-
end_per_testcase(Testcase, Config) when Testcase == variable_queue_requeue;
172-
Testcase == variable_queue_fold ->
173-
rabbit_ct_helpers:testcase_finished(Config, Testcase);
174167
end_per_testcase(Testcase, Config) ->
175168
rabbit_ct_helpers:testcase_finished(Config, Testcase).
176169

@@ -1576,39 +1569,6 @@ variable_queue_requeue_ram_beta2(VQ0, _Config) ->
15761569
{_, VQ8} = rabbit_variable_queue:ack(AcksAll, VQ7),
15771570
VQ8.
15781571

1579-
variable_queue_fold(Config) ->
1580-
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
1581-
?MODULE, variable_queue_fold1, [Config]).
1582-
1583-
variable_queue_fold1(Config) ->
1584-
with_fresh_variable_queue(
1585-
fun variable_queue_fold2/2,
1586-
?config(variable_queue_type, Config)).
1587-
1588-
variable_queue_fold2(VQ0, _Config) ->
1589-
{PendingMsgs, RequeuedMsgs, FreshMsgs, VQ1} =
1590-
variable_queue_with_holes(VQ0),
1591-
Count = rabbit_variable_queue:depth(VQ1),
1592-
Msgs = lists:sort(PendingMsgs ++ RequeuedMsgs ++ FreshMsgs),
1593-
lists:foldl(fun (Cut, VQ2) ->
1594-
test_variable_queue_fold(Cut, Msgs, PendingMsgs, VQ2)
1595-
end, VQ1, [0, 1, 2, Count div 2,
1596-
Count - 1, Count, Count + 1, Count * 2]).
1597-
1598-
test_variable_queue_fold(Cut, Msgs, PendingMsgs, VQ0) ->
1599-
{Acc, VQ1} = rabbit_variable_queue:fold(
1600-
fun (M, _, Pending, A) ->
1601-
MInt = msg2int(M),
1602-
Pending = lists:member(MInt, PendingMsgs), %% assert
1603-
case MInt =< Cut of
1604-
true -> {cont, [MInt | A]};
1605-
false -> {stop, A}
1606-
end
1607-
end, [], VQ0),
1608-
Expected = lists:takewhile(fun (I) -> I =< Cut end, Msgs),
1609-
Expected = lists:reverse(Acc), %% assertion
1610-
VQ1.
1611-
16121572
%% same as test_variable_queue_requeue_ram_beta but randomly changing
16131573
%% the queue mode after every step.
16141574
variable_queue_mode_change(Config) ->

0 commit comments

Comments
 (0)