Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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|
andQC.after_fork do |worker, cpid|
hooks like Unicorn has, and a test to cover the connection problem and the hooks.