Skip to content

Commit

Permalink
Fix crash when vnode Pid vanishes during stat calc
Browse files Browse the repository at this point in the history
  • Loading branch information
russelldb committed Jun 14, 2013
1 parent 365d180 commit 068c148
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/riak_core_stat.erl
Expand Up @@ -169,13 +169,20 @@ safe_trunc(X) ->
%% Provide aggregate stats for vnode queues. Compute instantaneously for now,
%% may need to cache if stats are called heavily (multiple times per seconds)
vnodeq_stats() ->
VnodesInfo = [{Service, element(2, erlang:process_info(Pid, message_queue_len))} ||
VnodesInfo = [{Service, vnodeq_len(Pid)} ||
{Service, _Index, Pid} <- riak_core_vnode_manager:all_vnodes()],
ServiceInfo = lists:foldl(fun({S,MQL}, A) ->
orddict:append_list(S, [MQL], A)
end, orddict:new(), VnodesInfo),
lists:flatten([vnodeq_aggregate(S, MQLs) || {S, MQLs} <- ServiceInfo]).

vnodeq_len(Pid) ->
try
element(2, erlang:process_info(Pid, message_queue_len))
catch _ ->
0
end.

vnodeq_aggregate(_Service, []) ->
[]; % no vnodes, no stats
vnodeq_aggregate(Service, MQLs0) ->
Expand Down

0 comments on commit 068c148

Please sign in to comment.