Forum: Ruby on Rails resilience to database restart

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Da2573ea7ded6fa06b1e8f7dd293f680?d=identicon&s=25 (Guest)
on 2007-01-17 15:09
(Received via mailing list)
Hi, apologies if you've discussed this already, but I haven't seen it:

I'm using rails in a multiserver environment. There is one central
server which is used to run Postgres and Rails. Then there are several
satellite servers that are supposed to pick up tasks from the Postgres
database and execute them. The servers use ActiveRecord to connect to
the database, even though they don't run Rails. It's a rudimentary
distributed computed facility. Each satellite server runs a daemon that
checks the central DB for new tasks, and if it finds one, spawns a new
thread to execute that task.

Here's the problem: the central Postgres server is rebooted weekly.
When this happens, the satellite servers crash when they try to find
new tasks, and take down the threads they had spawned and were still

My idea was to catch all exceptions in the daemon processes, and
periodically try to reconnect, however it seems overkill to wrap every
statement in a begin-rescue block.
I was wondering if someone has a more elegant solution to suggest.

Also I've read about *ActiveRecord::Base.verification_timeout  *and was
hopeful, but I don't think it's suited for this case.

Any suggestions will be appreciated.
This topic is locked and can not be replied to.