From 068c1481ab389d8d781dff2a3fd2860bb735e844 Mon Sep 17 00:00:00 2001 From: Russell Brown Date: Fri, 14 Jun 2013 10:00:08 +0100 Subject: [PATCH] Fix crash when vnode Pid vanishes during stat calc --- src/riak_core_stat.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/riak_core_stat.erl b/src/riak_core_stat.erl index 377922b1c..1a1900f2d 100644 --- a/src/riak_core_stat.erl +++ b/src/riak_core_stat.erl @@ -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) ->