Skip to content

Commit 1835d72

Browse files
committed
Check process aliveness on remote nodes
1 parent cc6c303 commit 1835d72

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/rabbit_core_metrics_gc.erl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ gc_process(Table) ->
103103
end, none, Table).
104104

105105
gc_process(Pid, Table, Key) ->
106-
case erlang:is_process_alive(Pid) of
106+
case is_process_alive_in_cluster(Pid) of
107107
true ->
108108
none;
109109
false ->
@@ -151,7 +151,7 @@ gc_process_and_entity(Table, GbSet) ->
151151
end, none, Table).
152152

153153
gc_process_and_entity(Id, Pid, Table, Key, GbSet) ->
154-
case erlang:is_process_alive(Pid) orelse gb_sets:is_member(Id, GbSet) of
154+
case is_process_alive_in_cluster(Pid) orelse gb_sets:is_member(Id, GbSet) of
155155
true ->
156156
none;
157157
false ->
@@ -166,3 +166,18 @@ gc_process_and_entities(Table, QueueGbSet, ExchangeGbSet) ->
166166
gc_entity(Q, Table, Key, QueueGbSet),
167167
gc_entity(X, Table, Key, ExchangeGbSet)
168168
end, none, Table).
169+
170+
is_process_alive_in_cluster(Pid) ->
171+
Local = node(),
172+
case node(Pid) of
173+
Local ->
174+
is_process_alive(Pid);
175+
Remote ->
176+
case rabbit_misc:rpc_call(Remote, erlang, is_process_alive, [Pid]) of
177+
Bool when is_boolean(Bool) ->
178+
Bool;
179+
{badrpc, _} ->
180+
%% If the node is unreachable, the process might be dead
181+
false
182+
end
183+
end.

0 commit comments

Comments
 (0)