Bug #18006
closedResolv::DNS#getaddress takes minutes to resolve a domain with no DNS records in 3.0 (was quick in 2.7)
Description
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:
$ 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
$ 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
Updated by dee-see (Dominic Couture) almost 3 years ago
- Subject changed from Resolv#getaddress takes minutes to resolve a domain with no DNS records in 3.0 (was quick in 2.7) to Resolv::DNS#getaddress takes minutes to resolve a domain with no DNS records in 3.0 (was quick in 2.7)
Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago
- Status changed from Open to Assigned
- Assignee set to akr (Akira Tanaka)
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.
Updated by xtkoba (Tee KOBAYASHI) almost 3 years ago
Maybe related to #17748.
Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago
- Status changed from Assigned to Closed
- Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE
I tested this with RubyInstaller-head on Windows and the problem appears to have been resolved. Even without an empty :search
option, ruby raises an exception almost immediately. As 9edc162583a4f685332239f6249745ad9b518cbe has already been backported to Ruby 3.0, I expect this issue will be fixed in Ruby 3.0.2.