From patchwork Sun Feb 16 00:33:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 38664 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8AC0A27BBE2; Sun, 16 Feb 2025 00:37:56 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 69ADE27BBEA for ; Sun, 16 Feb 2025 00:37:55 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tjSev-00036U-Ks; Sat, 15 Feb 2025 19:37:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tjSeq-0002zD-80 for guix-patches@gnu.org; Sat, 15 Feb 2025 19:37:16 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tjSep-0002EA-QE for guix-patches@gnu.org; Sat, 15 Feb 2025 19:37:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=UaT4rgawepJh7wqy1gtXismocdOTk7hAXJVH8vM7PNo=; b=TXc2oCf7s5R5kVVKyPABiSS71gPKWFpJz7Ea8sKTh1XFFRz9xMaBs91LrVQ0Qx7cFNl61GFIooMbPYop5AChRvVii2AZAXHSvXPJT1zrBPsNtAFArasHycWT4N91vgA8zBnybM7rJgEHGMXbtY4hg8s45sFxJP+UiJgaYbDK5DZcZ9a+12sOUO1WWfc4eGjYQRYioOUjdoxSsoJviODkEs0adoqTSPazMUNu4h0xb0PPxAGIixHYRK4tuwlmc8pN8f5+361OGS5BIZAh7lb9wahlF7zYM2XpreHd2SzJnwRso1v8aq7TRND1wnJ+sKIYxWiK/xhoHxDq82gdreh0PQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tjSep-00046j-LM for guix-patches@gnu.org; Sat, 15 Feb 2025 19:37:15 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76314] [PATCH ruby-team 24/71] gnu: ruby-pg: Update to 1.5.9-0.378b7a3. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 16 Feb 2025 00:37:15 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76314 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76314@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 76314-submit@debbugs.gnu.org id=B76314.173966620615444 (code B ref 76314); Sun, 16 Feb 2025 00:37:15 +0000 Received: (at 76314) by debbugs.gnu.org; 16 Feb 2025 00:36:46 +0000 Received: from localhost ([127.0.0.1]:58732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjSeL-00040p-32 for submit@debbugs.gnu.org; Sat, 15 Feb 2025 19:36:46 -0500 Received: from 11.mo583.mail-out.ovh.net ([46.105.47.167]:37095) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjSeB-0003yI-5R for 76314@debbugs.gnu.org; Sat, 15 Feb 2025 19:36:36 -0500 Received: from director6.ghost.mail-out.ovh.net (unknown [10.108.17.189]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 4YwRg61ySLz1QVF for <76314@debbugs.gnu.org>; Sun, 16 Feb 2025 00:36:34 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-xzx6x (unknown [10.110.164.75]) by director6.ghost.mail-out.ovh.net (Postfix) with ESMTPS id EFD231FDE9; Sun, 16 Feb 2025 00:36:33 +0000 (UTC) Received: from ngraves.fr ([37.59.142.103]) by ghost-submission-5b5ff79f4f-xzx6x with ESMTPSA id i6uULxEzsWc5TgAAnq9/2g (envelope-from ); Sun, 16 Feb 2025 00:36:33 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-103G005264a95e9-ebcc-40e4-943f-e6a0fd8135eb, 9A8994E2D2D994E918F063C652E1CB4623A3A71F) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 176.179.137.22 Date: Sun, 16 Feb 2025 01:33:52 +0100 Message-ID: <20250216003503.6348-24-ngraves@ngraves.fr> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250216003503.6348-1-ngraves@ngraves.fr> References: <20250216003503.6348-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3680003845857338082 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehgedtvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeffgfduuefhuedtjeevleeutdefgfehieehudetjefhvdduleetjeehiefgteffjeenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhmvghsshgrghgvrdhtohdpphhorhhtrdhtohdptghonhhsuhhmvggpihhnphhuthdrthhonecukfhppeduvdejrddtrddtrddupddujeeirddujeelrddufeejrddvvddpfeejrdehledrudegvddruddtfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepjeeifedugeesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheekfegmpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=UaT4rgawepJh7wqy1gtXismocdOTk7hAXJVH8vM7PNo=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1739666194; v=1; b=AY96VThTLLWfIBG4U717jaMBjo1AlgY3Kdfj4d8SHjy7KTo4yIPiGpA2LphF0J/L9WRbm3th owZ6VZrv7T8UEYZKe/l5B2Ke656Qdri6HsfAIFVDCN1HbbcIUMqNb2qi1Tx+V6DrV10taCLCppF cvEzdC8/XStb297hdFo5MsyOfhUXmiQ7rDaU7obbClKt8upc1N2xfmj2tIYQXX3KjIHKSyrIHse vkD6Z/uujkIjM+4vfOViKycXBDWD+QKV95aRInIWOB2Vj/cCE/+d1BLQmQjrPQG0BCKDEatLrV2 xrWYNKVpTdXMDkcLCa0SHvpEhOlikeQtUox0FHiJqC3xA== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/ruby.scm (ruby-pg): Update to 1.5.9-0.378b7a3. Avoid indenting (the package is maintained and a version will soon catch up). Add patch. * gnu/packages/patches/ruby-pg-fix-connect-timeout.patch: Add patch. * gnu/local.mk: Record patch. --- gnu/local.mk | 1 + .../patches/ruby-pg-fix-connect-timeout.patch | 176 ++++++++++++++++++ gnu/packages/ruby.scm | 13 +- 3 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/ruby-pg-fix-connect-timeout.patch diff --git a/gnu/local.mk b/gnu/local.mk index ecb91de430..6b457b57ec 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2186,6 +2186,7 @@ dist_patch_DATA = \ %D%/packages/patches/ruby-latex-decode-fix-test.patch \ %D%/packages/patches/ruby-mustache-1.1.1-fix-race-condition-tests.patch \ %D%/packages/patches/ruby-nokogiri.patch \ + %D%/packages/patches/ruby-pg-fix-connect-timeout.patch \ %D%/packages/patches/ruby-x25519-automatic-fallback-non-x86_64.patch \ %D%/packages/patches/rust-1.64-fix-riscv64-bootstrap.patch \ %D%/packages/patches/rust-1.70-fix-rustix-build.patch \ diff --git a/gnu/packages/patches/ruby-pg-fix-connect-timeout.patch b/gnu/packages/patches/ruby-pg-fix-connect-timeout.patch new file mode 100644 index 0000000000..16fa10707d --- /dev/null +++ b/gnu/packages/patches/ruby-pg-fix-connect-timeout.patch @@ -0,0 +1,176 @@ +From: "Alexander J. Maidak" +https://github.com/ged/ruby-pg/pull/619 + +--- + lib/pg/connection.rb | 16 ++++++++++- + spec/helpers.rb | 13 +++++++++ + spec/pg/connection_spec.rb | 57 +++++++++++++++++++++++++------------- + 3 files changed, 65 insertions(+), 21 deletions(-) + +diff --git a/lib/pg/connection.rb b/lib/pg/connection.rb +index 2c9ecd8..572a2bf 100644 +--- a/lib/pg/connection.rb ++++ b/lib/pg/connection.rb +@@ -680,6 +680,7 @@ class PG::Connection + host_count = conninfo_hash[:host].to_s.count(",") + 1 + stop_time = timeo * host_count + Process.clock_gettime(Process::CLOCK_MONOTONIC) + end ++ connection_errors = [] + + poll_status = PG::PGRES_POLLING_WRITING + until poll_status == PG::PGRES_POLLING_OK || +@@ -720,7 +721,13 @@ class PG::Connection + else + connhost = "at \"#{host}\", port #{port}" + end +- raise PG::ConnectionBad.new("connection to server #{connhost} failed: timeout expired", connection: self) ++ connection_errors << "connection to server #{connhost} failed: timeout expired" ++ if connection_errors.count < host_count.to_i ++ new_conninfo_hash = rotate_hosts(conninfo_hash.compact) ++ send(:reset_start2, self.class.send(:parse_connect_args, new_conninfo_hash)) ++ else ++ raise PG::ConnectionBad.new(connection_errors.join("\n"), connection: self) ++ end + end + + # Check to see if it's finished or failed yet +@@ -733,6 +740,13 @@ class PG::Connection + raise PG::ConnectionBad.new(msg, connection: self) + end + end ++ ++ private def rotate_hosts(conninfo_hash) ++ conninfo_hash[:host] = conninfo_hash[:host].split(",").rotate.join(",") if conninfo_hash[:host] ++ conninfo_hash[:port] = conninfo_hash[:port].split(",").rotate.join(",") if conninfo_hash[:port] ++ conninfo_hash[:hostaddr] = conninfo_hash[:hostaddr].split(",").rotate.join(",") if conninfo_hash[:hostaddr] ++ conninfo_hash ++ end + end + + include Pollable +diff --git a/spec/helpers.rb b/spec/helpers.rb +index 7214ec1..bd546f5 100644 +--- a/spec/helpers.rb ++++ b/spec/helpers.rb +@@ -475,6 +475,19 @@ EOT + end + end + ++ class ListenSocket ++ attr_reader :port ++ def initialize(host = 'localhost', accept: true) ++ TCPServer.open( host, 0 ) do |serv| ++ if accept ++ Thread.new { begin loop do serv.accept end rescue nil end } ++ end ++ @port = serv.local_address.ip_port ++ yield self ++ end ++ end ++ end ++ + def check_for_lingering_connections( conn ) + conn.exec( "SELECT * FROM pg_stat_activity" ) do |res| + conns = res.find_all {|row| row['pid'].to_i != conn.backend_pid && ["client backend", nil].include?(row["backend_type"]) } +diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb +index 63d3585..8a5645a 100644 +--- a/spec/pg/connection_spec.rb ++++ b/spec/pg/connection_spec.rb +@@ -369,24 +369,38 @@ describe PG::Connection do + end + end + +- it "times out after connect_timeout seconds" do +- TCPServer.open( 'localhost', 54320 ) do |serv| ++ it "times out after 2 * connect_timeout seconds on two connections" do ++ PG::TestingHelpers::ListenSocket.new do |sock| + start_time = Time.now + expect { + described_class.connect( +- host: 'localhost', +- port: 54320, +- connect_timeout: 1, +- dbname: "test") ++ host: 'localhost,localhost', ++ port: sock.port, ++ connect_timeout: 1, ++ dbname: "test") + }.to raise_error do |error| + expect( error ).to be_an( PG::ConnectionBad ) +- expect( error.message ).to match( /timeout expired/ ) ++ expect( error.message ).to match( /timeout expired.*timeout expired/m ) + if PG.library_version >= 120000 +- expect( error.message ).to match( /\"localhost\"/ ) +- expect( error.message ).to match( /port 54320/ ) ++ expect( error.message ).to match( /\"localhost\".*\"localhost\"/m ) ++ expect( error.message ).to match( /port #{sock.port}/ ) + end + end + ++ expect( Time.now - start_time ).to be_between(1.9, 10).inclusive ++ end ++ end ++ ++ it "succeeds with second host after connect_timeout" do ++ PG::TestingHelpers::ListenSocket.new do |sock| ++ start_time = Time.now ++ conn = described_class.connect( ++ host: 'localhost,localhost,localhost', ++ port: "#{sock.port},#{@port},#{sock.port}", ++ connect_timeout: 1, ++ dbname: "test") ++ ++ expect( conn.port ).to eq( @port ) + expect( Time.now - start_time ).to be_between(0.9, 10).inclusive + end + end +@@ -768,7 +782,8 @@ describe PG::Connection do + end + + it "raises proper error when sending fails" do +- conn = described_class.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" ) ++ sock = PG::TestingHelpers::ListenSocket.new('127.0.0.1', accept: false){ } ++ conn = described_class.connect_start( '127.0.0.1', sock.port, "", "", "me", "xxxx", "somedb" ) + expect{ conn.exec 'SELECT 1' }.to raise_error(PG::UnableToSend, /no connection/){|err| expect(err).to have_attributes(connection: conn) } + end + +@@ -1650,11 +1665,12 @@ describe PG::Connection do + + + it "handles server close while asynchronous connect" do +- serv = TCPServer.new( '127.0.0.1', 54320 ) +- conn = described_class.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" ) +- expect( [PG::PGRES_POLLING_WRITING, PG::CONNECTION_OK] ).to include conn.connect_poll +- select( nil, [conn.socket_io], nil, 0.2 ) +- serv.close ++ conn = nil ++ PG::TestingHelpers::ListenSocket.new('127.0.0.1', accept: false)do |sock| ++ conn = described_class.connect_start( '127.0.0.1', sock.port, "", "", "me", "xxxx", "somedb" ) ++ expect( [PG::PGRES_POLLING_WRITING, PG::CONNECTION_OK] ).to include conn.connect_poll ++ select( nil, [conn.socket_io], nil, 0.2 ) ++ end + if conn.connect_poll == PG::PGRES_POLLING_READING + select( [conn.socket_io], nil, nil, 0.2 ) + end +@@ -1778,12 +1794,13 @@ describe PG::Connection do + end + + it "consume_input should raise ConnectionBad for a closed connection" do +- serv = TCPServer.new( '127.0.0.1', 54320 ) +- conn = described_class.connect_start( '127.0.0.1', 54320, "", "", "me", "xxxx", "somedb" ) +- while [PG::CONNECTION_STARTED, PG::CONNECTION_MADE].include?(conn.connect_poll) +- sleep 0.1 ++ conn = nil ++ PG::TestingHelpers::ListenSocket.new '127.0.0.1', accept: false do |sock| ++ conn = described_class.connect_start( '127.0.0.1', sock.port, "", "", "me", "xxxx", "somedb" ) ++ while [PG::CONNECTION_STARTED, PG::CONNECTION_MADE].include?(conn.connect_poll) ++ sleep 0.1 ++ end + end +- serv.close + expect{ conn.consume_input }.to raise_error(PG::ConnectionBad, /server closed the connection unexpectedly/){|err| expect(err).to have_attributes(connection: conn) } + expect{ conn.consume_input }.to raise_error(PG::ConnectionBad, /can't get socket descriptor|connection not open/){|err| expect(err).to have_attributes(connection: conn) } + end +-- +2.47.1 + diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm index 09d595004d..1c311ead85 100644 --- a/gnu/packages/ruby.scm +++ b/gnu/packages/ruby.scm @@ -8503,20 +8503,23 @@ alternative to Marshal for Object serialization.") (license license:expat))) (define-public ruby-pg + (let ((commit "378b7a35c12292625460ef2f33373de7114bf255") + (revision "0")) (package (name "ruby-pg") - (version "1.4.6") + (version (git-version "1.5.9" revision commit)) (home-page "https://github.com/ged/ruby-pg") (source (origin (method git-fetch) (uri (git-reference (url home-page) - (commit (string-append "v" version)))) + (commit commit))) (file-name (git-file-name name version)) (sha256 - (base32 - "0k7jgx7x7p6gbsbrv2l5rq27nff2nphnls1sdq525d82b068qnfm")))) + (base32 "1aq6kakyghgbb4yykxxl9ziaaa7jbdbyc7vz6avyxhlby1jkj0m8")) + (patches + (search-patches "ruby-pg-fix-connect-timeout.patch")))) (build-system ruby-build-system) (arguments (list @@ -8543,7 +8546,7 @@ alternative to Marshal for Object serialization.") (synopsis "Ruby interface to PostgreSQL") (description "Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL 9.3 and later.") - (license license:ruby))) + (license license:ruby)))) (define-public ruby-byebug (package