From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 683951F9FC for ; Thu, 25 Mar 2021 15:04:23 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D8FA5120A36; Fri, 26 Mar 2021 00:03:23 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 85E4D120A33 for ; Fri, 26 Mar 2021 00:03:21 +0900 (JST) Received: by filterdrecv-p3las1-699f5f7ff5-zpgll with SMTP id filterdrecv-p3las1-699f5f7ff5-zpgll-19-605CA671-9F 2021-03-25 15:04:17.774908621 +0000 UTC m=+160275.647789495 Received: from herokuapp.com (unknown) by ismtpd0156p1iad2.sendgrid.net (SG) with ESMTP id 8hgUUg6vRGmxOu6O83YTLQ for ; Thu, 25 Mar 2021 15:04:17.556 +0000 (UTC) Date: Thu, 25 Mar 2021 15:04:17 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79055 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17748 X-Redmine-Issue-Author: xdmx X-Redmine-Sender: jeremyevans0 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIPM6gii3hA7K2x=2Ff4ZbJPfK04Q6BqW=2FDhRGUqG?= =?us-ascii?Q?fV4PwxDV74JbepxJeQCbXN8IXj=2FCYD34JNx3L=2FZ?= =?us-ascii?Q?reFDObxbttJJme6naejrD8Fl6MOn=2FGuz9GIdZfW?= =?us-ascii?Q?k4Cb0Tmgrzwr9adp7qYeLea95zy5zo+x5BDLiXk?= =?us-ascii?Q?jH5qrtwoChpRWzAcE=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103020 Subject: [ruby-core:103020] [Ruby master Bug#17748] Ruby 3.0 takes a long time to resolv DNS of nonexistent domains X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/