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

Why not auto reconnect - Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking. #370

Closed
AvnerCohen opened this issue Sep 30, 2013 · 1 comment

Comments

@AvnerCohen
Copy link

So this is regarding this exception being thrown:

Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.

I'm wondering if you'll take a PR and if there is a foreseen issue with doing something like:

          if Process.pid != @pid
            reconnect and return if @autoreconnect
            raise InheritedError,
              "Tried to use a connection from a child process without reconnecting. " +
              "You need to reconnect to Redis after forking."
          end

So basically, if some configuration is turned on, try to reconnect automatically instead of basing this behavior on the upstream after_fork sequence.

I might be off, but it seems to me that this is how it's done in Dalli, the memcached client:

https://github.com/mperham/dalli/blob/master/lib/dalli/server.rb#L87

And a similar behavior in the mongo driver (did not spend the time to find the code, here is the spec though..:
And this autoreconnect spec in Mongo
https://github.com/mongodb/mongo-ruby-driver/blob/92963999304db8d933a898f8025edce5795c145c/spec/support/shared/socket.rb#L9

@pietern
Copy link
Collaborator

pietern commented Sep 30, 2013

Something like that would be nice, yes. This is already being discussed in #364, let's continue the discussion there.

@pietern pietern closed this as completed Sep 30, 2013
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

No branches or pull requests

2 participants