1

We are using legacy database that goes down unexpectedly. This is bad experience for the user and for us.

When doing a simple query, like: User.find(1) and database goes down, it will not throw the exception. Just hangs there until database comes back. Setting timeout did not seem to do any good either.

Running this: connected = ActiveRecord::Base.connection_pool.with_connection { |con| con.active? } rescue false also hangs when connection is lost

Is there any way to check if the database is there before actuall making an ActiveRecord call?

Rails - 4.1.15

Ruby - jruby-9.0.5.0

Database: as400 (db2)

5
  • try to add this to your database.yml pool: 5 Commented May 30, 2016 at 17:03
  • @Boltz0r We have it set for 20 in production. Does not solve the issue Commented May 30, 2016 at 17:04
  • I'm affraid i can't help then :( Commented May 30, 2016 at 17:04
  • Have you tried checking if active_record is rocking and rolling via: " ActiveRecord::Base.connection.active? " or does that hang it up as well? Commented May 30, 2016 at 21:40
  • If hitting Active Record leads to the drop you can use the "ActiveRecord::Base.connection.raw_connection" which will bypass ActiveRecord and allow you to hit the database directly. Commented May 30, 2016 at 21:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.