Hi all,
Ruby 1.6.8
Solaris 8/9
DBI 0.18
As a test, we took down one of our test database machines and tried to
connect to it. The problem is that, on Solaris boxes, it seems to
ignore the ‘timeout’ that we’ve wrapped the connection in. Here’s the
code:
Begin code
require "dbi"
require “timeout”
puts Time.now.to_s
dbh = nil
begin
begin
timeout(3){
dbh = DBI.connect(dsn,user,passwd)
}
rescue TimeoutError => e
puts "DBI timed out: #{e}"
exit
ensure
puts Time.now.to_s
end
rescue DBI::Error => e
puts "Oops: #{e}"
exit
rescue
puts "WTF? " + $!
exit
end
sth = dbh.prepare(“select sysdate from dual”) # oracle - replace as
needed
sth.execute
puts "Result: " + sth.fetch.to_s
sth.finish
dbh.disconnect
End code
On a linux box, this code works as expected. However, on both Solaris 8
and Solaris 9, it takes about 3 minutes to timeout. On the Solaris 9
box, I have the host hard coded in the /etc/hosts file, while the
Solaris 8 box uses DNS.
Checking netstat -a, it appears that the connection is just sitting in a
SYN_SENT state.
We also tried just shutting down the listener and the DB itself (while
leaving the host up) and that worked fine.
Any ideas?
Regards,
Dan