summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_core_metrics_gc.erl19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/rabbit_core_metrics_gc.erl b/src/rabbit_core_metrics_gc.erl
index e0d7781796..c2f9b1c271 100644
--- a/src/rabbit_core_metrics_gc.erl
+++ b/src/rabbit_core_metrics_gc.erl
@@ -103,7 +103,7 @@ gc_process(Table) ->
end, none, Table).
gc_process(Pid, Table, Key) ->
- case erlang:is_process_alive(Pid) of
+ case is_process_alive_in_cluster(Pid) of
true ->
none;
false ->
@@ -151,7 +151,7 @@ gc_process_and_entity(Table, GbSet) ->
end, none, Table).
gc_process_and_entity(Id, Pid, Table, Key, GbSet) ->
- case erlang:is_process_alive(Pid) orelse gb_sets:is_member(Id, GbSet) of
+ case is_process_alive_in_cluster(Pid) orelse gb_sets:is_member(Id, GbSet) of
true ->
none;
false ->
@@ -166,3 +166,18 @@ gc_process_and_entities(Table, QueueGbSet, ExchangeGbSet) ->
gc_entity(Q, Table, Key, QueueGbSet),
gc_entity(X, Table, Key, ExchangeGbSet)
end, none, Table).
+
+is_process_alive_in_cluster(Pid) ->
+ Local = node(),
+ case node(Pid) of
+ Local ->
+ is_process_alive(Pid);
+ Remote ->
+ case rabbit_misc:rpc_call(Remote, erlang, is_process_alive, [Pid]) of
+ Bool when is_boolean(Bool) ->
+ Bool;
+ {badrpc, _} ->
+ %% If the node is unreachable, the process might be dead
+ false
+ end
+ end.