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

Expose ConnectionPool#reload #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

casperisfine
Copy link

Ref: mperham/connection_pool#140

When forking a process, you need to close existing connection to avoid sharing them across processes. shutdown does that, but it also mark the pool as no longer usable.

connection_pool 2.2.4 introduced #reload that discard existing connections, but let the pool be used again later. It's a much better fit for an after_fork callback.

Ref: mperham/connection_pool#140

When forking a process, you need to close existing connection
to avoid sharing them across processes. `shutdown` does that, but
it also mark the pool as no longer usable.

`connection_pool` `2.2.4` introduced `#reload` that discard existing
connections, but let the pool be used again later. It's a much better
fit for an `after_fork` callback.
@casperisfine
Copy link
Author

Also there's kind of two schools on how to deal with this.

Some libraries insist that it's the application's job to call the proper callback on their libraries when they fork, so in this case HTTPPersistent#reload. Which I admit is cleaner, but also sometimes is hard, as the relevant object are sometimes buried deep in private variables.

Some other libraries instead add a fork detection mechanism (generally @saved_pid != Process.pid), so that they automatically discard connections after fork.

If you are open for the later, I'd be happy to provide a PR.

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.

None yet

2 participants