Skip to content

Commit

Permalink
Remove raising conect_timeout from 1 to 2 seconds
Browse files Browse the repository at this point in the history
This will be removed in libpq of PostgreSQL-17 by this commit:
  postgres/postgres@105024a
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.
  • Loading branch information
larskanis committed Sep 9, 2024
1 parent cb35e3f commit ae228ba
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions lib/pg/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/pg/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ae228ba

Please sign in to comment.