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.6 required=3.0 tests=BAYES_00, 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=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 D96D01F9FC for ; Thu, 25 Mar 2021 11:08:22 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id DB28312097E; Thu, 25 Mar 2021 20:07:12 +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 1F1B1120976 for ; Thu, 25 Mar 2021 20:07:07 +0900 (JST) Received: by filterdrecv-p3iad2-7d7c446bd4-znxjr with SMTP id filterdrecv-p3iad2-7d7c446bd4-znxjr-20-605C6F09-9A 2021-03-25 11:07:53.521679135 +0000 UTC m=+146099.149647671 Received: from herokuapp.com (unknown) by geopod-ismtpd-canary-0 (SG) with ESMTP id U3wpl4iHSUeFV2Se33PMHA for ; Thu, 25 Mar 2021 11:07:53.456 +0000 (UTC) Date: Thu, 25 Mar 2021 11:07:53 +0000 (UTC) From: xdmx@email.it Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 79048 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17748 X-Redmine-Issue-Author: xdmx X-Redmine-Sender: xdmx 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?LjO=2FkhInSe1ToOBON5VWKhYSYopezHVj7ew4KrzVH1SsPc6UedvG39cGqIxUOm?= =?us-ascii?Q?0w7F0BWBk03QDyc1sAkzWCBj194Yy5=2FkzI93gPc?= =?us-ascii?Q?6pG9hyC1wQf3P0j15Ee=2FkL65OIXmNXwLhKc23az?= =?us-ascii?Q?DJR8Ue=2F9vjg4NWFza2UXLtHbt+MjLOpM8to35J5?= =?us-ascii?Q?SZaVQiPRUmGg+7di=2Fcspk3787ZX5+1qejRQ=3D=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103013 Subject: [ruby-core:103013] [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 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/