Skip to content

Commit 6a00753

Browse files
Merge pull request #4459 from rabbitmq/mergify/bp/v3.10.x/pr-4458
Fix report crashing priority queues (backport #4458)
2 parents 3f7d7c3 + 4c636c4 commit 6a00753

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

deps/rabbit/src/rabbit_priority_queue.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,18 @@ info(backing_queue_status, #state{bq = BQ, bqss = BQSs}) ->
419419
end, nothing, BQSs);
420420
info(head_message_timestamp, #state{bq = BQ, bqss = BQSs}) ->
421421
find_head_message_timestamp(BQ, BQSs, '');
422+
info(online, _) ->
423+
'';
422424
info(Item, #state{bq = BQ, bqss = BQSs}) ->
423425
fold0(fun (_P, BQSN, Acc) ->
424-
Acc + BQ:info(Item, BQSN)
426+
add(Acc, BQ:info(Item, BQSN))
425427
end, 0, BQSs);
426428
info(Item, #passthrough{bq = BQ, bqs = BQS}) ->
427429
BQ:info(Item, BQS).
428430

431+
add(Acc, Value) when is_number(Acc), is_number(Value) -> Acc + Value;
432+
add(_, Value) -> Value.
433+
429434
invoke(Mod, {P, Fun}, State = #state{bq = BQ}) ->
430435
pick1(fun (_P, BQSN) -> BQ:invoke(Mod, Fun, BQSN) end, P, State);
431436
invoke(Mod, Fun, State = #state{bq = BQ, max_priority = P}) ->

deps/rabbit/test/priority_queue_SUITE.erl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ groups() ->
2727
{overflow_reject_publish_dlx, [], [reject]},
2828
dropwhile_fetchwhile,
2929
info_head_message_timestamp,
30+
unknown_info_key,
3031
matching,
3132
purge,
3233
requeue,
@@ -397,6 +398,19 @@ info_head_message_timestamp1(_Config) ->
397398
PQ:delete_and_terminate(a_whim, BQS6),
398399
passed.
399400

401+
unknown_info_key(Config) ->
402+
{Conn, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
403+
Q = <<"info-priority-queue">>,
404+
declare(Ch, Q, 3),
405+
publish(Ch, Q, [1, 2, 3]),
406+
407+
{ok, [{pid, _Pid}, {unknown_key, ''}]} = info(Config, Q, [pid, unknown_key]),
408+
409+
delete(Ch, Q),
410+
rabbit_ct_client_helpers:close_channel(Ch),
411+
rabbit_ct_client_helpers:close_connection(Conn),
412+
passed.
413+
400414
ram_duration(_Config) ->
401415
QName = rabbit_misc:r(<<"/">>, queue, <<"ram_duration-queue">>),
402416
Q0 = rabbit_amqqueue:pseudo_queue(QName, self()),
@@ -518,4 +532,13 @@ queue_pid(Config, Nodename, Q) ->
518532
[Pid] = [P || [{name, Q1}, {pid, P}] <- Info, Q =:= Q1],
519533
Pid.
520534

535+
info(Config, Q, InfoKeys) ->
536+
Nodename = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
537+
{ok, Amq} = rabbit_ct_broker_helpers:rpc(
538+
Config, Nodename,
539+
rabbit_amqqueue, lookup, [rabbit_misc:r(<<"/">>, queue, Q)]),
540+
Info = rabbit_ct_broker_helpers:rpc(
541+
Config, Nodename,
542+
rabbit_classic_queue, info, [Amq, InfoKeys]),
543+
{ok, Info}.
521544
%%----------------------------------------------------------------------------

0 commit comments

Comments
 (0)