From patchwork Tue Jan 21 18:36:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 37365 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 39CBF27BBEA; Tue, 21 Jan 2025 18:46:16 +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=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED 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 5A77F27BBE2 for ; Tue, 21 Jan 2025 18:46:15 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taJGM-0001jL-Mt; Tue, 21 Jan 2025 13:46:12 -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 1taJFI-0000dF-Gv for guix-patches@gnu.org; Tue, 21 Jan 2025 13:45:06 -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 1taJFG-0004LW-Sq for guix-patches@gnu.org; Tue, 21 Jan 2025 13:45:03 -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=4pAnCHC5pfJwmEMg0WWHZfqX5oJcSV9ZbLXSMsP45QA=; b=RaKgKjPL6/UVHDGXKt5MSQaSYtXYH9p5DihoKCgaYaKsZzSD1dN9qWFYxHXM8C3c1EnTHBhX1BwjpZNjB5aZGp4HkdsDAnw9I1mNNzO9mbUizf0bdqUndXYyxghUySl0pIEzfagAUJlYX6QRIHieOQapscgtv+EtOKjtC8o8vSISp177EYBVj5LKVsT5ePt7nMyytKClXGWgc8NTox/NO8vNJdsSdC/SLtqR6Jpwxxn+C8dWEFLXOzjT2ZhjzOLKqRdeSOFJwCowXoVawC1xDG59OfAlLzipZqN+sDpeSIMknn1qIJhf+ajp0jQPOkjE9ck1nxwdEp3R0SoPn5Orgg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1taJFG-00067K-LW for guix-patches@gnu.org; Tue, 21 Jan 2025 13:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75737] [PATCH v2 024/118] 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: Tue, 21 Jan 2025 18:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75737 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75737@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 75737-submit@debbugs.gnu.org id=B75737.173748507123281 (code B ref 75737); Tue, 21 Jan 2025 18:45:02 +0000 Received: (at 75737) by debbugs.gnu.org; 21 Jan 2025 18:44:31 +0000 Received: from localhost ([127.0.0.1]:56459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1taJEk-00063O-E4 for submit@debbugs.gnu.org; Tue, 21 Jan 2025 13:44:31 -0500 Received: from 10.mo575.mail-out.ovh.net ([46.105.79.203]:49153) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1taJ9Q-0005ZP-R1 for 75737@debbugs.gnu.org; Tue, 21 Jan 2025 13:39:03 -0500 Received: from director4.ghost.mail-out.ovh.net (unknown [10.108.2.211]) by mo575.mail-out.ovh.net (Postfix) with ESMTP id 4Ycww25LXgz1bc9 for <75737@debbugs.gnu.org>; Tue, 21 Jan 2025 18:38:58 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-gr7wc (unknown [10.110.164.77]) by director4.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 749421FE90; Tue, 21 Jan 2025 18:38:58 +0000 (UTC) Received: from ngraves.fr ([37.59.142.106]) by ghost-submission-5b5ff79f4f-gr7wc with ESMTPSA id x4rFE8Lpj2cuWAEAHOLm5g (envelope-from ); Tue, 21 Jan 2025 18:38:58 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-106R0069784d7a3-b702-4c2d-9a79-8cc905492dc3, 4AD4F6D9E29B644C883BCAB2D4411A241F789B85) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.92.117.144 Date: Tue, 21 Jan 2025 19:36:44 +0100 Message-ID: <20250121183835.2080-24-ngraves@ngraves.fr> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250121183835.2080-1-ngraves@ngraves.fr> References: <20250121183835.2080-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 16844025557521392354 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefuddrudejvddgkeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepfffgudeuhfeutdejveeluedtfefgheeiheduteejhfdvudelteejheeigfetffejnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpmhgvshhsrghgvgdrthhopdhpohhrthdrthhopdgtohhnshhumhgvpghinhhpuhhtrdhtohenucfkphepuddvjedrtddrtddruddpledtrdelvddruddujedrudeggedpfeejrdehledrudegvddruddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepjeehjeefjeesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheejhegmpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=4pAnCHC5pfJwmEMg0WWHZfqX5oJcSV9ZbLXSMsP45QA=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1737484738; v=1; b=aGRjdBdfeOokRdLdNOIkdOAzMuseiE0EBMGNQWJZ6w/sbu/CQzqHabamUNsDXmIkXUHP1t2P OSVN8cd8ZqF3lKcvxfbPvO3VOeqSdg/yh8OS1mYf5O4SZ7KsmPh/TGIVvyvf+8qXvzV8YLCqxbe YGBR+CCzla66fNhzTSJU+LdRvRV2Qn76h+lV+fB1GiLU4S1B1Wkwwy1IbzNwub3PR6Fwlp9YyTI 6srOur6e2RoAcduaZpzG1R9JCZGXMyIcUY8cy451lI5en6KOoHGJd2kvqZQ+933U4dJDeYGiVp6 dtkPbfgrn/SJOTItuR5hulcl7S1KvvS/QBVlDfk43jEUQ== 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 847708b873..74778a8791 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2187,6 +2187,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 af0152bb74..511085e9ba 100644 --- a/gnu/packages/ruby.scm +++ b/gnu/packages/ruby.scm @@ -8540,20 +8540,23 @@ (define-public ruby-redcloth (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 @@ -8580,7 +8583,7 @@ (define-public ruby-pg (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