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

Reconnect on unicorn USR2 #10

jdowning opened this Issue Aug 21, 2015 · 2 comments


None yet
2 participants
Copy link

jdowning commented Aug 21, 2015

When restarting unicorn with the USR2 signal, a new master is created and workers are forked off. In my config/unicorn.rb, before switching to readthis, I had Rails.cache.reconnect to reconnect to redis after forking. I believe this was an implementation of the redis-store gem, which you aren't using here.

How would you suggest I reconnect the unicorn worker to the redis-based cache with readthis? Thanks!


This comment has been minimized.

Copy link

sorentwo commented Aug 21, 2015

@justindowning: You don't need to force redis to reconnect, it will automatically reconnect when it encounters inheritance errors. There is a test for this exact use case in the redis-rb repository: fork_safety_test.rb

readthis uses connection_pool to manage multiple connections. While it would be technically possible to iterate over each connection in the pool and force a reconnect, it isn't necessary. In fact, the connection pool documentation even mandates that connections be self repairing!

There is no provision for repairing or checking the health of a connection; connections should be self-repairing. This is true of the Dalli and Redis clients.

So, good news all around. You don't need to do anything!

@sorentwo sorentwo closed this Aug 21, 2015


This comment has been minimized.

Copy link

jdowning commented Aug 21, 2015

Great to hear! Thanks for the quick and thorough response! 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment