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=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no 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 421DC1F9FC for ; Thu, 25 Mar 2021 12:41:56 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7721F120A12; Thu, 25 Mar 2021 21:40:53 +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 2E22E120A04 for ; Thu, 25 Mar 2021 21:40:50 +0900 (JST) Received: by filterdrecv-p3iad2-7d7c446bd4-mhgkr with SMTP id filterdrecv-p3iad2-7d7c446bd4-mhgkr-20-605C850A-2D 2021-03-25 12:41:46.35161173 +0000 UTC m=+151726.099111040 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id 36HGTwmmR8KwE4eoiAROWg for ; Thu, 25 Mar 2021 12:41:46.231 +0000 (UTC) Date: Thu, 25 Mar 2021 12:41:46 +0000 (UTC) From: jean.boussier@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79052 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17748 X-Redmine-Issue-Author: xdmx X-Redmine-Sender: byroot 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?AchqQMoUBMcQgz7gop0XiYUiatGIY7E61JGsTL4FvjdNt4zWpYLDiXcnQtUX=2FY?= =?us-ascii?Q?GijcfE664lw6nBJTixRTup=2FfGvjT8+PBSNiZYxY?= =?us-ascii?Q?J7yYcDkxxGxhZEIi9SOYjrmQWguEM8LshI+0=2FsH?= =?us-ascii?Q?SLNJEw=2F0bZJLXNxkslBxGaXy7jaalYuRxW4MsMh?= =?us-ascii?Q?yrOJ9L4V=2FMA5ON2GRraXrQWdnSd=2F2YxEKGTm5Un?= =?us-ascii?Q?qDnx8xctfpwsKRlu0=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103017 Subject: [ruby-core:103017] [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 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/