Skip to content

Commit 533d2df

Browse files
Make rabbit_networking:close_connection/2 more benign
The function relies on a fanout to all running cluster nodes which in turn check their local connection process group. All errors that might arise are ignored. There are at least two scenarios where the current behavior makes little sense: * A connection process has just terminated (but is still present in the stats DB) * A node could not respond (or respond in time) to the fanout In both cases claiming that connection pid is "not a connection pid" is misleading and likely will leave the user puzzled. This change makes connection_close/2 more benign: it simply logs a warning and returns instead of throwing. There are only two call sites that use it: rabbitmqctl and an HTTP API handler, so the chances of non-connection pids passed in are pretty slim. Per discussion with @gerhard.
1 parent b822e85 commit 533d2df

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/rabbit_networking.erl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,16 @@ connection_info_all(Items, Ref, AggregatorPid) ->
305305
connections()).
306306

307307
close_connection(Pid, Explanation) ->
308-
rabbit_log:info("Closing connection ~p because ~p~n", [Pid, Explanation]),
309308
case lists:member(Pid, connections()) of
310-
true -> rabbit_reader:shutdown(Pid, Explanation);
311-
false -> throw({error, {not_a_connection_pid, Pid}})
309+
true ->
310+
Res = rabbit_reader:shutdown(Pid, Explanation),
311+
rabbit_log:info("Closing connection ~p because ~p~n", [Pid, Explanation]),
312+
Res;
313+
false ->
314+
rabbit_log:warning("Asked to close connection ~p (reason: ~p) "
315+
"but no running cluster node reported it as an active connection. Was it already closed? ~n",
316+
[Pid, Explanation]),
317+
ok
312318
end.
313319

314320
force_connection_event_refresh(Ref) ->

0 commit comments

Comments
 (0)