ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
@ 2021-03-25 11:07 xdmx
  2021-03-25 12:16 ` [ruby-core:103015] " jean.boussier
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: xdmx @ 2021-03-25 11:07 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been reported by xdmx (Eric Bloom).

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103015] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
@ 2021-03-25 12:16 ` jean.boussier
  2021-03-25 12:28 ` [ruby-core:103016] " jean.boussier
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jean.boussier @ 2021-03-25 12:16 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been updated by byroot (Jean Boussier).


I was able to reproduce on both 3.0.0-p0 as well as the current `ruby_3_0` branch.

However it seems to be limited to the linux builds, it does not repo on macOS.

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91080

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103016] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
  2021-03-25 12:16 ` [ruby-core:103015] " jean.boussier
@ 2021-03-25 12:28 ` jean.boussier
  2021-03-25 12:41 ` [ruby-core:103017] " jean.boussier
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jean.boussier @ 2021-03-25 12:28 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been updated by byroot (Jean Boussier).


I ran a quick profiler:

All the time is spent waiting on the socket to be readable:
```
==================================
  Mode: wall(1000)
  Samples: 75017 (0.00% miss rate)
  GC: 1 (0.00%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
     75016 (100.0%)       75016 (100.0%)     IO#wait_readable
...
```

The long time it takes it likely the default socket timeout of the system.

That wait_readable is in `Resolv::DNS::Requester#request`

```
IO#wait_readable (<cfunc>:1)
  samples:  75016 self (100.0%)  /   75016 total (100.0%)
  callers:
    75016  (  100.0%)  Resolv::DNS::Requester#request
```

Likely this one: https://github.com/ruby/ruby/blob/ad8842c06d26ee634f90008efecf1cd4d76342df/lib/resolv.rb#L677

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91081

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103017] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
  2021-03-25 12:16 ` [ruby-core:103015] " jean.boussier
  2021-03-25 12:28 ` [ruby-core:103016] " jean.boussier
@ 2021-03-25 12:41 ` jean.boussier
  2021-03-25 15:04 ` [ruby-core:103020] " merch-redmine
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jean.boussier @ 2021-03-25 12:41 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been updated by byroot (Jean Boussier).


The bug seem to be introduced by https://github.com/ruby/ruby/commit/9682db065158da5fa4ec8a3bc267da45b429b92c

Reverting it makes the resolution complete fast.

Ref: https://bugs.ruby-lang.org/issues/12838

cc @jeremyevans0

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91082

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103020] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
                   ` (2 preceding siblings ...)
  2021-03-25 12:41 ` [ruby-core:103017] " jean.boussier
@ 2021-03-25 15:04 ` merch-redmine
  2021-03-25 18:36 ` [ruby-core:103024] " jean.boussier
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: merch-redmine @ 2021-03-25 15:04 UTC (permalink / raw)
  To: ruby-core

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


I couldn't reproduce the bug on Windows or OpenBSD.  Since the bug appears to be limited to Linux, maybe we can just revert the behavior on Linux. #12838 is a corner case, certainly the timeout for invalid domains is worse.  Here's a pull request for that approach: https://github.com/ruby/resolv/pull/7

Someone who runs Linux may want to develop a better fix that doesn't timeout and handles duplicate responses.

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91085

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103024] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
                   ` (3 preceding siblings ...)
  2021-03-25 15:04 ` [ruby-core:103020] " merch-redmine
@ 2021-03-25 18:36 ` jean.boussier
  2021-03-26  9:53 ` [ruby-core:103037] " k
  2021-04-08 12:53 ` [ruby-core:103303] " nehresma+rubybugs
  6 siblings, 0 replies; 8+ messages in thread
From: jean.boussier @ 2021-03-25 18:36 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been updated by byroot (Jean Boussier).


>  maybe we can just revert the behavior on Linux. #12838 is a corner case, certainly the timeout for invalid domains is worse.

I agree.

> Someone who runs Linux 

I was able to reproduce using Docker on macOS, I presume Docker on Windows would work as well. For whoever would like to find a better fix.

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91089

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103037] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
                   ` (4 preceding siblings ...)
  2021-03-25 18:36 ` [ruby-core:103024] " jean.boussier
@ 2021-03-26  9:53 ` k
  2021-04-08 12:53 ` [ruby-core:103303] " nehresma+rubybugs
  6 siblings, 0 replies; 8+ messages in thread
From: k @ 2021-03-26  9:53 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been updated by rhenium (Kazuki Yamaguchi).


I was able to reproduce the issue on my Linux box and was digging into this. There actually seem to be two issues behind.

 - If a search list is not given to Resolv::DNS and also the local domain name of the system is not set (Socket.gethostname is not fully qualified), the same query for the domain name is generated twice.

    https://github.com/ruby/resolv/pull/8

 - The change in [Bug #12838] didn't fully resolve the root issue.

    https://github.com/ruby/resolv/pull/9

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91100

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ruby-core:103303] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
  2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
                   ` (5 preceding siblings ...)
  2021-03-26  9:53 ` [ruby-core:103037] " k
@ 2021-04-08 12:53 ` nehresma+rubybugs
  6 siblings, 0 replies; 8+ messages in thread
From: nehresma+rubybugs @ 2021-04-08 12:53 UTC (permalink / raw)
  To: ruby-core

Issue #17748 has been updated by nehresman (Nathan Ehresman).


Since this was backported and included in 2.7.3 it impacts people upgrading from 2.7.2 as well.  We were just bitten by this when upgrading to 2.7.3 to address the unrelated CVE-2021-28965.

----------------------------------------
Bug #17748: Ruby 3.0 takes a long time to resolv DNS of nonexistent domains
https://bugs.ruby-lang.org/issues/17748#change-91388

* Author: xdmx (Eric Bloom)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
I'm running into a subtle bug when trying to resolv a nonexistent domain.
```
$ ruby -v          
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.051897333
```

This works fine and it's fast, but as soon as I try to run this on 3.0:
```
$ rbenv local 3.0.0
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
$ irb
require 'resolv'
=> true
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('thisisaninvaliddomain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 76.314624548
t = Time.now ; Resolv::DNS.open { |dns| dns.getresources('domain.com', Resolv::DNS::Resource::IN::A) } ; Time.now - t
=> 0.081165397
```

In this case the resolver takes a very long time to return a result, and it only happens with nonexistent domains. For those that exist it's running fast.

What's weird is that the only change I do is switching from 2.7 to 3.0, and then I suddenly have this problem.

The above code was run on my local machine (Arch Linux) with Ruby installed through rbenv. I've also double checked it on a completely different machine (server running Ubuntu 18.04) that is connected from a different country and I'm having the exact same problem. In that case Ruby was compiled directly from the source and installed on the server.

So this should potentially exclude any connection issue (as locally with 2.7 is fast, and it was tried in 2 different places), the way it was installed (rbenv vs source) and the distro (Arch vs Ubuntu). I asked someone running macos and ruby 3.0 and it seems that it was fast there, so maybe it's only a linux related bug, I wasn't able to get other people to try.

Resolving the domain with `resolvctl` is also running fast:
```
$ time resolvectl query thisisaninvaliddomain.com
thisisaninvaliddomain.com: resolve call failed: 'thisisaninvaliddomain.com' not found
resolvectl query thisisaninvaliddomain.com  0.00s user 0.01s system 71% cpu 0.009 total
```



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-04-08 12:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25 11:07 [ruby-core:103013] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains xdmx
2021-03-25 12:16 ` [ruby-core:103015] " jean.boussier
2021-03-25 12:28 ` [ruby-core:103016] " jean.boussier
2021-03-25 12:41 ` [ruby-core:103017] " jean.boussier
2021-03-25 15:04 ` [ruby-core:103020] " merch-redmine
2021-03-25 18:36 ` [ruby-core:103024] " jean.boussier
2021-03-26  9:53 ` [ruby-core:103037] " k
2021-04-08 12:53 ` [ruby-core:103303] " nehresma+rubybugs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).