[erlang-questions] start_child() on simple_one_for_one supervisor -> {error, {already_started, ...}} ???

mighty mighty.fine@REDACTED
Tue Dec 16 09:22:46 CET 2008


P.S. How scalable is registering processes? E.g., Is registering 64K
processes not going to scale, as well as potentially impact others
using registered names? It seems like there's a hash table for
registered processes in register.c that starts off pretty small.

On Sun, Dec 14, 2008 at 3:19 AM, Nicolas Charpentier
<nc-dated-1234437579.6f32a2@REDACTED> wrote:
> Hi,
>
> mighty wrote:
>>
>> I have a basic simple_one_for_one supervisor that I cannot start
>> multiple children from -- the first call to start_child() works, the
>> second call to start_child() returns
>> {error,{already_started,<0.38.0>}}. My supervisor is
>> simple_one_for_one, so I'd expect to hit the ?is_simple() handling of
>> start_child in supervisor.erl, which should go through
>> supervisor:do_start_child_i() without any fuss, and definitely not
>> return {error, {already_started, ...}} out of
>> supervisor:handle_start_child().
>>
>
> In your case {error, {already_started, _}} is returned by
> gen_server:start_link/4 (and then returned by supervisor:start_child/2.
>
> gen_server:start_link/4 returns an error because you are trying to register
> 2 processes with the same name (my_node).
> Replace the function my_node:start_link/1 with:
>
> start_link(Instance) when is_integer(Instance)->
>     error_logger:info_report([[my_node,start_link,Instance,self()]]),
>     Name = atom_to_list(?MODULE) ++ "_" ++ integer_to_list(Instance),
>     gen_server:start_link({local, list_to_atom(Name)},?MODULE,[],[]).
>
>
>
> Regards,
>
> ----
> Nicolas Charpentier
> http://charpi.net
>



More information about the erlang-questions mailing list