[erlang-questions] Threads with outdated list of links

Kenneth Lundin kenneth.lundin@REDACTED
Tue Feb 19 09:18:49 CET 2013


process_info does only operate on local processes.  Your filtering
does not work as you expect because you will get an exception (bad
argument) on every remote process.

This is probably the explanation you are seeking for.

/Kenneth, Erlang/OTP Ericsson

On 2/19/13, Brian Picciano <mediocregopher@REDACTED> wrote:
> I hope it's not bad form to post this to two places at once. I already put
> this on stack overflow but I figured I might get a better response here.
> Anyway:
> I have a process that lots of threads make links to in order to associate
> themselves with this process. I made the system this way so that at any
> time I can easily see who is associated to the central process without
> having to also keep track of any lists inside of the application itself. I
> can simply do process_info(self(),links) and erlang keeps track of which
> processes are still alive or not, etc....
> At least, I thought so, until I found out that the list being returned on
> this thread isn't accurate at this moment:
> % P is my central pid
> (node@REDACTED)212> P.
> <0.803.0>
> % Get all the links to it
> (node@REDACTED)213> {links,L} = process_info(P,links).
> {links,[<0.29179.155>,<0.6492.250>,<0.29990.293>|...]}
> % Counting out all the links
> (node@REDACTED)214> length(L).
> 31154
> % Filtering out all of the dead processes, put them in Lf
> (node@REDACTED)215> Lf = lists:filter(fun(Pid) -> try process_info(Pid,links)
> of {links,_} -> true; _ -> false catch _:_ -> false end end, L).
> [<0.29179.155>,<0.6492.250>,<0.29990.293>,<0.23619.530>|...]
> % Lf is only about half the size, half the linked processes are dead!
> (node@REDACTED)216> length(Lf).
> 15654
> % Proof that the links haven't changed in the interim
> (node@REDACTED)217> {links,L} = process_info(P,links).
> {links,[<0.29179.155>,<0.6492.250>,<0.29990.293>|...]}
> The only thing I can think of that would cause this is network connectivity
> issues, since some of the links may come from threads on a node on another
> machine. Is that a possible explanation for this? And is there a way to
> make the thread clean up its link list?

More information about the erlang-questions mailing list