ryandotsmith/queue_classic — pull request #216 by 2468ben (2014-05-02 19:36:26+00:00)
Title: 207 forking in v3

Tries to fix #207

When a worker forks, the forked process inherits its master connection. Then, after the forked process is finished (exactly where I can't pinpoint), the master connection closes.
At least in the test suite, the teardown function deletes all jobs, and that's when a PG::UnableToSend error pulls up.

The weird thing is that when I check the connection's status, and the connect_poll property (which ActiveRecord uses to check PG connections), they're both fine. The only way -yet- that I can tell the connection's broken is to execute and handle the PGError.

My current solution is to check the PGError for "PG::UnableToSend", and if true then reconnect and re-execute the query. I'm still hoping to find out exactly when the connection closed, without relying on an error.

I also added ```QC.before_fork do |worker|``` and ```QC.after_fork do |worker, cpid|``` hooks like Unicorn has, and a test to cover the connection problem and the hooks.