[erlang-questions] Strange inet_gethost_native:gethostbyname behavior

Raimo Niskanen raimo+erlang-questions@REDACTED
Wed Jan 24 10:47:51 CET 2018


On Tue, Jan 23, 2018 at 07:02:22PM -0800, David Welton wrote:
> Hi,
> 
> I ssh'ed into a system to see what was causing connection problems.
> 
> inet_gethost_native:gethostbyname("google.com", inet). kept failing
> with {error, try_again}.
> 
> Started up a new Erlang shell and tried the same thing.  It worked fine.
> 
> Killed the external process it was using, inet_gethost and retried,
> and it started working.
> 
> This is an older Erlang: erts-6.4.1.2 but inet_gethost hasn't seen a
> lot of changes lately, going on the git logs.
> 
> Any ideas what 1) may cause this and 2) how to get around it?  The
> system is stuck not being able to do DNS lookups, which is
> problematic, to say the least.
> 
> Thanks
> -- 
> David N. Welton
> 
> http://www.welton.it/davidw/
> http://www.dedasys.com/


This sounds like a job for the API call
    inet_gethost_native:control(soft_restart)

It happens that libc in a native resolver process caches DNS replies for
too long, maybe after some network reconfiguration, and this call
restarts all native resolver processes the node uses.

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list