Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1819b2

Browse files
mkuratczykmichaelklishin
authored andcommitted
rabbit_quorum_queue:stat/2 use find_leader/1 (#15400)
This should deflake: make -C deps/rabbit ct-dynamic_qq t=cluster_size_3:takeover_on_failure
1 parent 573a19e commit c1819b2

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,17 +1169,16 @@ stat(Q) when ?is_amqqueue(Q) ->
11691169
-spec stat(amqqueue:amqqueue(), non_neg_integer()) -> {'ok', non_neg_integer(), non_neg_integer()}.
11701170

11711171
stat(Q, Timeout) when ?is_amqqueue(Q) ->
1172-
Leader = amqqueue:get_pid(Q),
11731172
try
1174-
case rabbit_fifo_client:stat(Leader, Timeout) of
1175-
{ok, _, _} = Success -> Success;
1176-
{error, _} -> {ok, 0, 0};
1177-
{timeout, _} -> {ok, 0, 0}
1173+
maybe
1174+
Leader ?= find_leader(Q),
1175+
{ok, _, _} = Result ?= rabbit_fifo_client:stat(Leader, Timeout),
1176+
Result
1177+
else
1178+
_ -> {ok, 0, 0}
11781179
end
11791180
catch
1180-
_:_ ->
1181-
%% Leader is not available, cluster might be in minority
1182-
{ok, 0, 0}
1181+
_:_ -> {ok, 0, 0}
11831182
end.
11841183

11851184
-spec purge(amqqueue:amqqueue()) ->

deps/rabbit/test/dynamic_qq_SUITE.erl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,18 @@ takeover_on(Config, Fun) ->
176176
arguments = Args,
177177
durable = true}),
178178
ok = rabbit_ct_broker_helpers:start_node(Config, A),
179-
ACh2 = rabbit_ct_client_helpers:open_channel(Config, A),
180-
#'queue.declare_ok'{message_count = 10} =
181-
amqp_channel:call(
182-
ACh2, #'queue.declare'{queue = QName,
183-
arguments = Args,
184-
durable = true}),
179+
180+
?awaitMatch(
181+
#'queue.declare_ok'{message_count = 10},
182+
begin
183+
ACh2 = rabbit_ct_client_helpers:open_channel(Config, A),
184+
amqp_channel:call(
185+
ACh2, #'queue.declare'{queue = QName,
186+
arguments = Args,
187+
durable = true,
188+
passive = true})
189+
end,
190+
60000),
185191
ok.
186192

187193
quorum_unaffected_after_vhost_failure(Config) ->

0 commit comments

Comments
 (0)