Project

General

Profile

Actions

Bug #18006

closed

Resolv::DNS#getaddress takes minutes to resolve a domain with no DNS records in 3.0 (was quick in 2.7)

Added by dee-see (Dominic Couture) 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
[ruby-core:104398]

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
Actions

Also available in: Atom PDF