If the code excute redis related function, it will raise
Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
when redis connect it will save the spork process.pid as @pid, then redis excute it will check the connect using ensure_connected
, which will check by Process.pid != @pid
. and these two pids are different, so it raise Redis::InheritedError.
By Google it,
Resque.after_fork do
Resque.redis.client.reconnect
end
and reconnect the redis client every spec
Both of them don't work for me.
After upgrade redis to 2.6.12, the problem resolved.