[erlang-questions] Diagnosing gen_server call timeouts

Danil Zagoskin z@REDACTED
Fri Sep 20 14:13:06 CEST 2019


You can use rpc for that:

rpc:call(node(RPid), erlang, process_info, [RPid, [dictionary,
current_stacktrace]]).

On Fri, Sep 20, 2019 at 2:57 PM Roger Lipscombe <roger@REDACTED>
wrote:

> Er, so I neglected to mention that the gen_server is remote (same
> host, different node), so process_info doesn't work :(
>
> On Fri, 20 Sep 2019 at 01:45, Max Lapshin <max.lapshin@REDACTED> wrote:
> >
> > Copy paste from our video_frame.erl:
> >
> >
> > send_frame(Stream, #video_frame{content = Content, codec = Codec, flavor
> = Flavor, dts = DTS} = Frame, SourceTag) when is_pid(Stream) ->
> >   Frame1 = case SourceTag of
> >     undefined -> Frame;
> >     _ -> Frame#video_frame{source = SourceTag}
> >   end,
> >   try gen_server:call(Stream, Frame1)
> >   catch
> >     exit:{normal, _} ->
> >       {error, stopped};
> >     exit:{noproc, _} ->
> >       {error, stopped};
> >     exit:{shutdown, _} ->
> >       {error, stopped};
> >     exit:{timeout, _}:Stack ->
> >       Dict = case process_info(Stream, dictionary) of
> >         {dictionary, Dict_} -> Dict_;
> >         undefined -> []
> >       end,
> >       RemoteStack = process_info(Stream, current_stacktrace),
> >       Name = case proplists:get_value(name, Dict, <<"dead stream">>) of
> >         N when is_binary(N) -> N;
> >         N when is_atom(N) -> N;
> >         N -> iolist_to_binary(io_lib:format("~p", [N]))
> >       end,
> >       Status = proplists:get_value(status, Dict),
> >       case Status of
> >         S when S == starting_transcoder -> ok;
> >         _ -> events:error("failed to send frame ~p,~p,~p,~p,
> source_tag=~p to ~s (~p) in status ~p\n~p\nremote stack:\n~p", [
> >                          Content, Codec, Flavor, round(DTS),
> Frame1#video_frame.source,
> >                          Name, Stream, Status, Stack, RemoteStack])
> >       end,
> >       % [io:format("~10.. s: ~p~n", [K,V]) || {K,V} <-
> process_info(Stream)]
> >       {error, timeout}
> >   end.
> >
> >
> >
> > this code is helping us for years.  You should remove video specific
> stuff.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Danil Zagoskin | z@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190920/7f366095/attachment.htm>


More information about the erlang-questions mailing list