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-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.7 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 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 A91B91F463 for ; Fri, 3 Jan 2020 13:49:49 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 41AA112093B; Fri, 3 Jan 2020 22:49:33 +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 38C7512093A for ; Fri, 3 Jan 2020 22:49:29 +0900 (JST) Received: by filterdrecv-p3las1-5bf99c48d-9bj9q with SMTP id filterdrecv-p3las1-5bf99c48d-9bj9q-18-5E0F4669-13 2020-01-03 13:49:29.405765788 +0000 UTC m=+654579.201290532 Received: from herokuapp.com (unknown [54.159.65.60]) by ismtpd0039p1iad2.sendgrid.net (SG) with ESMTP id HkB_jKlcQGO6uOPP_HqsBw for ; Fri, 03 Jan 2020 13:49:29.279 +0000 (UTC) Date: Fri, 03 Jan 2020 13:49:29 +0000 (UTC) From: shatrov@me.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72304 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 16476 X-Redmine-Issue-Author: kirs X-Redmine-Sender: kirs 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?h605rtfxHUz9JKWQv8rL01lKGkbDwBVz=2FBYWeiTyV=2FrLPERKYhoq4m5IfkhXjP?= =?us-ascii?Q?Pp=2FKVj4YYbSYHJ1TdLhtqMhVjrfqBIzAwhgFk6i?= =?us-ascii?Q?wwxBADaUjetqx2vr7cBbqYOeseexTnpukQucZfx?= =?us-ascii?Q?npIYV8sRh=2F+DA1=2F11pXKi+IeUIT++CaqEO6cl=2FF?= =?us-ascii?Q?U478dVdMQfS2QQ+fE38D+nD2RhI4onrEBRQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96642 Subject: [ruby-core:96642] [Ruby master Bug#16476] Socket.getaddrinfo cannot be interrupted by Timeout.timeout 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 #16476 has been reported by kirs (Kir Shatrov). ---------------------------------------- Bug #16476: Socket.getaddrinfo cannot be interrupted by Timeout.timeout https://bugs.ruby-lang.org/issues/16476 * Author: kirs (Kir Shatrov) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- It seems like the blocking syscall done by `Socket.getaddrinfo` blocks Ruby VM in a way that Timeout.timeout has no effect. See reproduction steps in getaddrinfo_interrupt.rb attached. This affects all modern Ruby versions, including the latest 2.7.0. Combined with default 10s resolv timeout on many Linux systems, this can have a very noticeable effect on production Ruby apps being not resilient to slow DNS resolutions, and being unable to fail fast even with `Timeout.timeout`. While https://bugs.ruby-lang.org/issues/15553 improves the situation, `Socket.getaddrinfo` is still blocking the VM and Timeout has no effect. I'd like to discuss what could be done to make that call non-blocking for threads in Ruby VM. ---Files-------------------------------- getaddrinfo_interrupt.rb (881 Bytes) -- https://bugs.ruby-lang.org/