Issue #18006 has been updated by jeremyevans0 (Jeremy Evans).

Assignee set to akr (Akira Tanaka)
Status changed from Open to Assigned

I was unable to recreate this issue in my OpenBSD environment. However, I was able to recreate the issue on Windows.  I think the issue is due to domain searching.  As a work around, you can try specifying an empty `search` option:

```
ruby -r resolv -e 'Resolv::DNS.new(nameserver: "8.8.8.8", search: []).getaddress("doesnotexist.deesee.xyz")'
```

With the empty `search` option, you should get results just as fast with and without the trailing dot.  However, if you are relying on domain searching to handle non-FQDN domain names, that wouldn't work for you.

----------------------------------------
Bug #18006: Resolv::DNS#getaddress takes minutes to resolve a domain with no DNS records in 3.0 (was quick in 2.7)
https://bugs.ruby-lang.org/issues/18006#change-92640

* Author: dee-see (Dominic Couture)
* Status: Assigned
* Priority: Normal
* Assignee: akr (Akira Tanaka)
* ruby -v: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Hello team,

Calling `getaddress` on a domain that returns `NXDOMAIN` takes 2.5 minutes in Ruby 3.0, unless the domain is in FQDN form (with a trailing dot). I'll try to take a look and figure out what's happening, but I'm not familiar with the Ruby code base so I wanted to report this first. I reproduced the issue on my local machine and on a VPS so this isn't a local network problem.

2.7:

``` shell
$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
16:42:49 dee-see@glacier:tmp$ time ruby -r resolv -e 'Resolv::DNS.new(nameserver: "8.8.8.8").getaddress("doesnotexist.deesee.xyz.")'
Traceback (most recent call last):
	1: from -e:1:in `<main>'
/home/dee-see/.rbenv/versions/2.7.2/lib/ruby/2.7.0/resolv.rb:379:in `getaddress': DNS result has no information for doesnotexist.deesee.xyz. (Resolv::ResolvError)

real	0m0.225s
user	0m0.091s
sys	0m0.020s
$ time ruby -r resolv -e 'Resolv::DNS.new(nameserver: "8.8.8.8").getaddress("doesnotexist.deesee.xyz")'
Traceback (most recent call last):
	1: from -e:1:in `<main>'
/home/dee-see/.rbenv/versions/2.7.2/lib/ruby/2.7.0/resolv.rb:379:in `getaddress': DNS result has no information for doesnotexist.deesee.xyz (Resolv::ResolvError)

real	0m0.291s
user	0m0.079s
sys	0m0.021s
```

3.0, notice the time on the second try

```shell
$ ruby -v
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
$ time ruby -r resolv -e 'Resolv::DNS.new(nameserver: "8.8.8.8").getaddress("doesnotexist.deesee.xyz.")'
/home/dee-see/.rbenv/versions/3.0.1/lib/ruby/3.0.0/resolv.rb:379:in `getaddress': DNS result has no information for doesnotexist.deesee.xyz. (Resolv::ResolvError)
	from -e:1:in `<main>'

real	0m0.240s
user	0m0.102s
sys	0m0.031s
$ time ruby -r resolv -e 'Resolv::DNS.new(nameserver: "8.8.8.8").getaddress("doesnotexist.deesee.xyz")'
/home/dee-see/.rbenv/versions/3.0.1/lib/ruby/3.0.0/resolv.rb:379:in `getaddress': DNS result has no information for doesnotexist.deesee.xyz (Resolv::ResolvError)
	from -e:1:in `<main>'

real	2m30.363s
user	0m0.122s
sys	0m0.021s
```




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>