Skip to content

Commit a782a77

Browse files
the-mikedavismergify[bot]
authored andcommitted
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. (cherry picked from commit a65ceb6)
1 parent ede60f9 commit a782a77

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
@@ -1519,7 +1519,14 @@ notify_policy_changed(Q) when ?is_amqqueue(Q) ->
15191519

15201520
consumers(Q) when ?amqqueue_is_classic(Q) ->
15211521
QPid = amqqueue:get_pid(Q),
1522-
delegate:invoke(QPid, {gen_server2, call, [consumers, infinity]});
1522+
try
1523+
delegate:invoke(QPid, {gen_server2, call, [consumers, infinity]})
1524+
catch
1525+
exit:_ ->
1526+
%% The queue process exited during the call.
1527+
%% Note that `delegate:invoke/2' catches errors but not exits.
1528+
[]
1529+
end;
15231530
consumers(Q) when ?amqqueue_is_quorum(Q) ->
15241531
QPid = amqqueue:get_pid(Q),
15251532
case ra:local_query(QPid, fun rabbit_fifo:query_consumers/1) of

0 commit comments

Comments
 (0)