Skip to content

Commit 79af645

Browse files
committed
QQ: Make rabbit_fifo_client:stat/2 backwards compatible.
1 parent 59e1606 commit 79af645

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

deps/rabbit/src/rabbit_fifo_client.erl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,16 @@ stat(Leader) ->
521521
stat(Leader, Timeout) ->
522522
%% short timeout as we don't want to spend too long if it is going to
523523
%% fail anyway
524-
case ra:local_query(Leader, fun rabbit_fifo:query_stat/1, Timeout) of
525-
{ok, {_, {R, C}}, _} -> {ok, R, C};
526-
{error, _} = Error -> Error;
527-
{timeout, _} = Error -> Error
524+
%% TODO: the overview is too large to be super efficient
525+
%% but we use it for backwards compatibilty
526+
case ra:member_overview(Leader, Timeout) of
527+
{ok, #{machine := #{num_ready_messages := R,
528+
num_checked_out := C}}, _} ->
529+
{ok, R, C};
530+
{error, _} = Error ->
531+
Error;
532+
{timeout, _} = Error ->
533+
Error
528534
end.
529535

530536
update_machine_state(Server, Conf) ->

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,12 @@ stat(Q, Timeout) when ?is_amqqueue(Q) ->
11661166
Leader = amqqueue:get_pid(Q),
11671167
try
11681168
case rabbit_fifo_client:stat(Leader, Timeout) of
1169-
{ok, _, _} = Success -> Success;
1170-
{error, _} -> {ok, 0, 0};
1171-
{timeout, _} -> {ok, 0, 0}
1169+
{ok, _, _} = Success ->
1170+
Success;
1171+
{error, _} ->
1172+
{ok, 0, 0};
1173+
{timeout, _} ->
1174+
{ok, 0, 0}
11721175
end
11731176
catch
11741177
_:_ ->

deps/rabbit/test/quorum_queue_SUITE.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,9 +3767,9 @@ queue_length_limit_policy_cleared(Config) ->
37673767
{<<"overflow">>, <<"reject-publish">>}]),
37683768
timer:sleep(1000),
37693769
RaName = ra_name(QQ),
3770-
QueryFun = fun rabbit_fifo:overview/1,
3771-
?awaitMatch({ok, {_, #{config := #{max_length := 2}}}, _},
3772-
rpc:call(Server, ra, local_query, [RaName, QueryFun]),
3770+
% QueryFun = fun rabbit_fifo:overview/1,
3771+
?awaitMatch({ok, #{machine := #{config := #{max_length := 2}}}, _},
3772+
ra:member_overview({RaName, Server}),
37733773
?DEFAULT_AWAIT),
37743774
#'confirm.select_ok'{} = amqp_channel:call(Ch, #'confirm.select'{}),
37753775
ok = publish_confirm(Ch, QQ),
@@ -3778,8 +3778,8 @@ queue_length_limit_policy_cleared(Config) ->
37783778
wait_for_messages_ready(Servers, RaName, 3),
37793779
fail = publish_confirm(Ch, QQ),
37803780
ok = rabbit_ct_broker_helpers:clear_policy(Config, 0, <<"max-length">>),
3781-
?awaitMatch({ok, {_, #{config := #{max_length := undefined}}}, _},
3782-
rpc:call(Server, ra, local_query, [RaName, QueryFun]),
3781+
?awaitMatch({ok, #{machine := #{config := #{max_length := undefined}}}, _},
3782+
ra:member_overview({RaName, Server}),
37833783
?DEFAULT_AWAIT),
37843784
ok = publish_confirm(Ch, QQ),
37853785
wait_for_messages_ready(Servers, RaName, 4).

0 commit comments

Comments
 (0)