[erlang-bugs] supervisor transient child error?

Michael Truog mjtruog@REDACTED
Wed Sep 9 11:06:27 CEST 2015


On 09/09/2015 01:31 AM, Siri Hansen wrote:
> Hi Michael,
>
> I think that the child spec is kept in the supervisor so that one is allowed to do supervisor:restart_child/2. This has been the behavior at least as far back as the git repository goes. And given that the text was changed as far back as OTP-R8B,  I don't think that the old documentation is a reason for changing this behavior.
That is fine, but documentation could be added to make sure this behavior is clear, since it is contrary to the definition of "transient":
1a passing especially quickly into and out of existence
(http://www.merriam-webster.com/dictionary/transient)

I assume temporary has a similar problem.

>
> Regards
> /siri
>
>
> 2015-07-10 3:53 GMT+02:00 Michael Truog <mjtruog@REDACTED <mailto:mjtruog@REDACTED>>:
>
>     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
>
>     _______________________________________________
>     erlang-bugs mailing list
>     erlang-bugs@REDACTED <mailto:erlang-bugs@REDACTED>
>     http://erlang.org/mailman/listinfo/erlang-bugs
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150909/a4bbbd34/attachment.htm>


More information about the erlang-bugs mailing list