[erlang-bugs] supervisor transient child error?

Michael Truog mjtruog@REDACTED
Fri Jul 10 03:53:27 CEST 2015


Hi,

I have noticed that when the supervisor has a child process with the childspec restart set to transient, and the process terminates in a way that is not abnormal, the childspec remains within the supervisor.  This appears to be an error based on old documentation: "When a |temporary|child dies for any reason or a |transient|child dies normally, the child is removed from the supervisor." (http://www.erlang.org/documentation/doc-4.8.2/lib/stdlib-1.6.1/doc/html/supervisor.html). The new documentation states: "a transientchild process will be restarted only if it terminates abnormally, i.e. with another exit reason than normal, shutdownor {shutdown,Term}" (http://www.erlang.org/doc/man/supervisor.html), and this statement is true with the current supervisor code.

Is it an error that transient processes that terminate in a way that is not abnormal do not get removed from the supervisor?  I think it is, but I am not sure if this was accepted legacy behavior that the documentation didn't want to contradict.  I have an example below with output:

-module(test).
-behaviour(supervisor).
-export([start_link/0, test_child/0, test/0, init/1]).
start_link() ->
     supervisor:start_link({local, ?MODULE}, ?MODULE, []).
test_child() ->
     {ok, erlang:spawn_link(fun() -> erlang:exit(normal) end)}.
test() ->
     ChildSpec = {test, {test, test_child, []}, transient, 2000, worker, []},
     supervisor:start_child(?MODULE, ChildSpec).
init([]) ->
     {ok, {{one_for_one, 5, 300}, []}}.


Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
1> {ok, Sup} = test:start_link().
{ok,<0.35.0>}
2> erlang:unlink(Sup).
true
3> {ok, P} = test:test().
{ok,<0.38.0>}
4> erlang:is_process_alive(P).
false
5> supervisor:which_children(test).
[{test,undefined,worker,[]}]
6> test:test().
{error,already_present}

Isn't keeping the entry in the supervisor, after a termination that is not abnormal, an error?

Thanks,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150709/47f62c6a/attachment.htm>


More information about the erlang-bugs mailing list