Skip to content

Commit 20164d8

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

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
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
_:_ ->

0 commit comments

Comments
 (0)