Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

207 forking in v3 #216

Closed
wants to merge 9 commits into from
Closed

Conversation

2468ben
Copy link

@2468ben 2468ben commented May 2, 2014

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.

@2468ben
Copy link
Author

2468ben commented May 2, 2014

I updated the test to run two forked jobs in a row, and the second one will throw a PG::UnableToSend error (without the fix).
That should demonstrate that it immediately disconnects, and not just on teardown. Still figuring out exactly when.

@ukd1
Copy link
Contributor

ukd1 commented May 6, 2014

@2468ben build failing due to #212

@senny senny mentioned this pull request Jun 8, 2015
@ukd1 ukd1 added this to the 4.0.0 milestone Jul 23, 2019
@ukd1 ukd1 closed this Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is forking supposed to work for 3.0.0?
2 participants