nesquena / backburner

Simple and reliable beanstalkd job queue for ruby
http://nesquena.github.com/backburner
MIT License
428 stars 68 forks source link

How to recover DB connection between two jobs in production ? #90

Open geoffroymontel opened 9 years ago

geoffroymontel commented 9 years ago

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 ?

freysie commented 8 years ago

+1

contentfree commented 8 years ago

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.

prashantham commented 8 years ago

has the hook system available on latest version?