Guru needed: connecting to a second (remote) db that may not

hi,

My rails app connects to 2 databases a local one and a remote one. No
problems there… The problem is that the remote database may or may not
be
available at any given time. My problem: when the remote db is
unavailable,
any time my code tries to query the remote database it hangs for a few
minutes until it times-out. I would very much like to change the
timeout
value to something lower so my rails app can continue to operate at
least
semi-normally while the remote db is unavailable.

i tried using verification_timeout, not sure if i did something wrong
but it
didn’t work… tried Mysql::OPT_CONNECT_TIMEOUT (or something like that)
and
that didn’t seem to do much either, again not sure if i used it right
(both
have slim to none documentation)… lastly i tried wrapping different
stuff
in a Timeout::timeout block (establish_connection, connect code in
connection_adapter code, etc etc) NO DICE…

can anybody help me with this issue?

thanks

stuart

Hi, I’m not a guru, though I have a suggestion.

Fall out of rails and back to system commands, ping the database and if
there is no responce then raise an exception to get out of the remote
query
block.

Example:

raise (DangitException, ‘not again’) if /Destination Host Unreachable/m
=~
ping -w 2 x.x.x.x

its quick but not the best.

cheers,

  • trav

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs