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

Redis::InheritedError #92

Closed
bbuchalter opened this issue Jun 5, 2014 · 1 comment
Closed

Redis::InheritedError #92

bbuchalter opened this issue Jun 5, 2014 · 1 comment

Comments

@bbuchalter
Copy link

When using Unicorn (or any other forking server) I receive this error from delayed_job:
Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.

It doesn't seem to break anything, but errors make me sad. So, I'm thinking this method needs away for folks to hook into to be able to call Rails.cache.reconnect and make the errors go away.

I'm happy to open a PR, but perhaps you could advise me on how to structure this hook in a way that would make you happy?

@betamatt
Copy link
Collaborator

betamatt commented Jun 5, 2014

You receive that error in a web process or in the DJ process? Unicorn, or any choice of webserver, doesn't have anything to do with DJ.

Yes, it's possible the main DJ gem (https://github.com/collectiveidea/delayed_job) needs to provide a hook for forking behavior since daemonizing results in a fork. You'd need to reopen a redis connection if you had opened one during app initialization (I've used a lazy proxy to prevent this.) It would be tough to add this to Lifecycle since before/after fork are executed as class methods before the worker is instantiated. I guess adding a hook on Worker that builds up an array of blocks wouldn't be a bad way to go. Can't imagine anyone would object to that behavior as long as it's a new method.

I suspect most people who've run into this in the past have done a quick alias_method_chain on the Worker's after_fork method to get around this. https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/worker.rb#L92

(closing/wrong repo)

@betamatt betamatt closed this as completed Jun 5, 2014
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