backburner icon indicating copy to clipboard operation
backburner copied to clipboard

How to recover DB connection between two jobs in production ?

Open geoffroymontel opened this issue 9 years ago • 3 comments

Using backburner with ThreadsOnFork in production with Rails 4.2 and postgresql.

If I stop and restart the postgresql service on my Linux box, Rails can reconnect to the new postgresql service but the workers can't access to the new instance of the database.

I'm getting a PG::UnableToSend: no connection to the server error when the postgresql service is stopped and after it's restarted.

Some people had the same kind of problem with other queueing systems, and they recommend to run something like this

Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }

How can I achieve this with Backburner ?

Should I put this in config.on_error ?

geoffroymontel avatar Mar 28 '15 10:03 geoffroymontel

+1

freysie avatar Oct 08 '15 03:10 freysie

I've actually been working on this the past couple days (it's coming as a side effect of handling dead connections to beanstalk).

The first revision will use the existing hook system so you'll likely need to either reopen the world class that you're using or subclass and extend.

contentfree avatar Oct 08 '15 04:10 contentfree

has the hook system available on latest version?

prashantham avatar Mar 01 '16 13:03 prashantham