From ae228bac8c9f8e7e97f04762970cff51163a5c73 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 9 Sep 2024 08:07:50 +0200 Subject: [PATCH] Remove raising conect_timeout from 1 to 2 seconds This will be removed in libpq of PostgreSQL-17 by this commit: https://github.com/postgres/postgres/commit/105024a47238e33647d346264b4f6fe68a7287ed The adjustment of connect_timeout from 1 to 2 seconds was anyway only relevant due to libpq's internal rounding, which doesn't apply to ruby. --- lib/pg/connection.rb | 2 -- spec/pg/connection_spec.rb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pg/connection.rb b/lib/pg/connection.rb index 196a19d51..a326c8778 100644 --- a/lib/pg/connection.rb +++ b/lib/pg/connection.rb @@ -653,8 +653,6 @@ def cancel # Track the progress of the connection, waiting for the socket to become readable/writable before polling it if (timeo = conninfo_hash[:connect_timeout].to_i) && timeo > 0 - # Lowest timeout is 2 seconds - like in libpq - timeo = [timeo, 2].max host_count = conninfo_hash[:host].to_s.count(",") + 1 stop_time = timeo * host_count + Process.clock_gettime(Process::CLOCK_MONOTONIC) end diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb index df5438ab3..a4bfd79ad 100644 --- a/spec/pg/connection_spec.rb +++ b/spec/pg/connection_spec.rb @@ -377,7 +377,7 @@ end end - expect( Time.now - start_time ).to be_between(1.9, 10).inclusive + expect( Time.now - start_time ).to be_between(0.9, 10).inclusive end end