El Lunes, 28 de Diciembre de 2009, Iñaki Baz Castillo escribió:
> Hi, in my app I'm trying to test if a DB connection works during startup. 
> However I've realized that, in case the DB host doesn't reply, the emthod 
> "test_connection" gets blocked forever, and the worst: it blocks the
>  entire  Ruby process so threading is not possible:

It's even worse: Sequel blocks the entire Ruby process when it cannot connect 
to a database:


---- test_sequel_error_connection.rb ----
require "sequel"
require "timeout"

Thread.new do
  sleep 3
  puts "[starting thread for Sequel]"
  db = Sequel.connect("mysql://lala:[email protected]/lala")
  # db.test_connection
  db.table_exists?(:lolo)
  puts "[thread end]"
end

loop do
  printf "."
  sleep 0.1
end
---------------------------------------------


~# ruby test_sequel_error_connection.rb
..............................[starting thread for Sequel]
.


and gets blocked entirely (kill -9 is the only solution).


How to avoid it? This is: if my Ruby app uses various database in different 
servers and one of those servers crashes, then my Ruby app would get totally 
blocked when performing a query for that database!

Regards.



-- 
Iñaki Baz Castillo <[email protected]>

--

You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.


Reply via email to