[erlang-bugs] : bug: Protocol: "inet_tcp": register/listen error: eaddrinuse while starting a node

Raimo Niskanen <>
Thu Sep 25 15:27:12 CEST 2008


On Thu, Sep 25, 2008 at 04:12:37PM +0400, Igor Goryachev wrote:
> Raimo Niskanen <> writes:
> 
> > On Fri, Sep 05, 2008 at 10:46:09PM +0400, Igor Goryachev wrote:
> >> Hello everybody.
> >> 
> >> It's me again. I've posted this message some time ago, but have not got
> >> any response. I confirm that this bug is reproduced (seems to be
> >> floating bug) when using R12B-3 version and '-kernel inet_dist_listen_min
> >> XXXX inet_dist_listen_max YYYY' when XXXX number equal to YYYY.
> >
> > Hi Igor.
> >
> > Yes why not. We see no harm in your patch and will apply it.
> > It will be part of the next service release.
> >
> > Sorry about the slow response to your first mail.
> 
> Hi, Raimo.
> 
> Thank you very much for the response. I do not really understand why
> does it occur (well, I have no time for this investigation), but this
> tiny patch fixes that weird behaviour.
> 

It *should* occur when an erlang node has a(n) incoming connection(s)
to the listen port, and then closes the port either by getting
killed by the OS or by itself. Then the TCP port ends up in the 
infamous state TIME_WAIT aka 2MSL_TIMEOUT which often is approximately
30 seconds. During that time the port can not be bound to.

> Good luck.
> 
> 
> >
> >> 
> >> 
> >> 
> >
> >> To: 
> >> From: Igor Goryachev <>
> >> Date: Tue, 05 Feb 2008 18:00:30 +0300
> >> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)
> >> Cc: 
> >> Subject: [erlang-bugs] bug: Protocol: "inet_tcp": register/listen error:
> >> 	eaddrinuse while starting a node
> >> Xref: goryachev.yandex.ru lists.erlang-questions:11465 lists.erlang-bugs:456
> >> 
> >> Hi, everyone!
> >> 
> >> I have noticed some troubles while starting node with '-kernel
> >> inet_dist_listen_min 5290 inet_dist_listen_max 5290' options. And
> >> everything works fine when these options are omitted. 
> >> 
> >> The output is here:
> >> 
> >> ===========
> >> {progress,preloaded}
> >> {progress,kernel_load_completed}
> >> {progress,modules_loaded}
> >> {start,heart}
> >> {start,error_logger}
> >> {start,application_controller}
> >> {progress,init_kernel_started}
> >> {apply,{application,load,[{application,stdlib,[{description,"ERTS  CXC 138 10"},{vsn,"1.14.5"},{id,[]},{modules,[base64,beam_lib,c,calendar,dets,dets_server,dets_sup,dets_utils,dets_v8,dets_v9,dict,digraph,digraph_utils,edlin,edlin_expand,epp,eval_bits,erl_bits,erl_compile,erl_eval,erl_expand_records,erl_internal,erl_lint,erl_parse,erl_posix_msg,erl_pp,erl_scan,erl_tar,error_logger_file_h,error_logger_tty_h,escript,ets,file_sorter,filelib,filename,gb_trees,gb_sets,gen,gen_event,gen_fsm,gen_server,io,io_lib,io_lib_format,io_lib_fread,io_lib_pretty,lib,lists,log_mf_h,math,ms_transform,orddict,ordsets,otp_internal,pg,pool,proc_lib,proplists,qlc,qlc_pt,queue,random,regexp,sets,shell,shell_default,slave,sofs,string,supervisor,supervisor_bridge,sys,timer,win32reg,zip]},{registered,[timer_server,rsh_starter,take_over_monitor,pool_master,dets]},{applications,[kernel]},{included_applications,[]},{env,[]},{start_phases,undefined},{maxT,infinity},{maxP,infinity}]}]}}
> >> {progress,applications_loaded}
> >> {apply,{application,start_boot,[kernel,permanent]}}
> >> {error_logger,{{2008,2,5},{17,18,42}},"Protocol: ~p: register/listen error: ~p~n",["inet_tcp",eaddrinuse]}
> >> {error_logger,{{2008,2,5},{17,18,42}},crash_report,[[{pid,<0.21.0>},{registered_name,net_kernel},{error_info,{error,badarg}},{initial_call,{gen,init_it,[gen_server,<0.18.0>,<0.18.0>,{local,net_kernel},net_kernel,{'',shortnames,15000},[]]}},{ancestors,[net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[<0.18.0>]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,377},{stack_size,21},{reductions,331}],[]]}
> >> {error_logger,{{2008,2,5},{17,18,42}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[['',shortnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
> >> {error_logger,{{2008,2,5},{17,18,42}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
> >> {error_logger,{{2008,2,5},{17,18,42}},crash_report,[[{pid,<0.7.0>},{registered_name,[]},{error_info,{shutdown,{kernel,start,[normal,[]]}}},{initial_call,{application_master,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_reply,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader,error_logger,file_server_2,fixtable_server,global_group,global_name_server,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,ddll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,application_controller,application_master,application_starter,auth,code,code_aux,packages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_loader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_server,prim_file,global,global_group,global_search,group,heart,hipe_unified_loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethost_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,disk_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,prim_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sctp,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},normal]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0.6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,987},{stack_size,21},{reductions,2063}],[]]}
> >> {apply,{application,start_boot,[stdlib,permanent]}}
> >> {error_logger,{{2008,2,5},{17,18,42}},std_info,[{application,kernel},{exited,{shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]}
> >> {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}"}
> >> 
> >> Crash dump was written to: erl_crash.dump
> >> Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}})
> >> ===========
> >> 
> >> 
> >> After a little bit of investigation I've noticed, that there is no
> >> '{reuseaddr, true}' socket option in the lib/kernel/src/inet_tcp_dist.erl. If
> >> I add this option, recompile inet_tcp_dist.erl, put it into proper
> >> place, everything works fine like when mentioned above kernel options
> >> are omitted.
> >> 
> >> The tiny patch is included.
> >> 
> >> 
> >> 
> >> -- 
> >> Igor Goryachev
> >> Yandex development team.
> >> 
> >
> >> --- inet_tcp_dist.erl.orig	2008-02-05 17:28:51.000000000 +0300
> >> +++ inet_tcp_dist.erl	2008-02-05 17:31:24.000000000 +0300
> >> @@ -62,7 +62,7 @@
> >>  %% ------------------------------------------------------------
> >>  
> >>  listen(Name) ->
> >> -    case do_listen([{active, false}, {packet,2}]) of
> >> +    case do_listen([{active, false}, {packet,2}, {reuseaddr, true}]) of
> >>  	{ok, Socket} ->
> >>  	    TcpAddress = get_tcp_address(Socket),
> >>  	    {_,Port} = TcpAddress#net_address.address,
> >
> >> _______________________________________________
> >> erlang-bugs mailing list
> >> 
> >> http://www.erlang.org/mailman/listinfo/erlang-bugs
> >
> >> 
> >> 
> >> -- 
> >> Igor Goryachev
> >> Yandex development team.
> >
> >> _______________________________________________
> >> erlang-bugs mailing list
> >> 
> >> http://www.erlang.org/mailman/listinfo/erlang-bugs
> >
> > -- 
> >
> > / Raimo Niskanen, Erlang/OTP, Ericsson AB
> >
> 
> -- 
> Igor Goryachev
> Yandex development team.

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-bugs mailing list