Skip to content

Match error while doing process handoff in dynamic supervisor #254

@flaviogrossi

Description

@flaviogrossi

I think there is a missing nil check here while the dynamic supervisor handles the process handoff when a cluster node goes down.

The function get_item/2 can in fact return nil, which should be handled to avoid crashing the caller.

This is an error trace to clarify the case:

** (MatchError) no match of right hand side value: nil
   (horde 0.8.4) lib/horde/dynamic_supervisor_impl.ex:219: Horde.DynamicSupervisorImpl.handle_cast/2
   (stdlib 3.15.2) gen_server.erl:695: :gen_server.try_dispatch/4
   (stdlib 3.15.2) gen_server.erl:771: :gen_server.handle_msg/6
   (stdlib 3.15.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:\"$gen_cast\", {:relinquish_child_process, 326189823806954505632234248165147259649}}" tags=default pid=<0.5768.185> module=gen_server function=error_info/7 file=gen_server.erl line=949 vm_pid=1942 host=vm1-3vqpiro-39 erl_level=error crash_reason="{%MatchError{term: nil}, [{Horde.DynamicSupervisorImpl, :handle_cast, 2, [file: 'lib/horde/dynamic_supervisor_impl.ex', line: 219]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 695]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 771]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}]}" domain=[:otp] error_logger="%{report_cb: &:gen_server.format_log/1, tag: :error}" gl=<0.3031.0> mfa="{:gen_server, :error_info, 7}"

I cannot reliably reproduce the issue, but maybe the whole handle_cast should be just be a noop in case get_item returns nil?

Quickly scanning the file, a similar pattern can also occur in the handoff_child function i believe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions