Skip to content

Commit

Permalink
Merge pull request #590 from larskanis/conn_timeout
Browse files Browse the repository at this point in the history
Remove raising conect_timeout from 1 to 2 seconds
  • Loading branch information
larskanis authored Sep 9, 2024
2 parents cb35e3f + ae228ba commit 5db4b55
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 5db4b55

Please sign in to comment.