Skip to content

Commit a65ceb6

Browse files
committed
rabbit_amqqueue: Catch exits when reading classic Q consumers/1
`delegate:invoke/2` catches errors but not exits of the delegate process. Another process might query for a classic queue's consumers while the classic queue is being deleted or otherwise terminating and that would result in an exit of the calling process previously.
1 parent a9c48ef commit a65ceb6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,14 @@ notify_policy_changed(Q) when ?is_amqqueue(Q) ->
15231523

15241524
consumers(Q) when ?amqqueue_is_classic(Q) ->
15251525
QPid = amqqueue:get_pid(Q),
1526-
delegate:invoke(QPid, {gen_server2, call, [consumers, infinity]});
1526+
try
1527+
delegate:invoke(QPid, {gen_server2, call, [consumers, infinity]})
1528+
catch
1529+
exit:_ ->
1530+
%% The queue process exited during the call.
1531+
%% Note that `delegate:invoke/2' catches errors but not exits.
1532+
[]
1533+
end;
15271534
consumers(Q) when ?amqqueue_is_quorum(Q) ->
15281535
QPid = amqqueue:get_pid(Q),
15291536
case ra:local_query(QPid, fun rabbit_fifo:query_consumers/1) of

0 commit comments

Comments
 (0)