首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Resque-ui导致错误消息“已尝试使用来自子进程的连接”重做

Resque-ui导致错误消息“已尝试使用来自子进程的连接”重做
EN

Stack Overflow用户
提问于 2012-09-28 06:06:17
回答 2查看 1K关注 0票数 0

我使用的是Resque 1.22.0,Resque-status 0.3.3,一切运行正常。如果我包含救援-ui,我会得到错误(来自队列):

代码语言:javascript
复制
failed: #<Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.>

从rake任务代码中删除resque-ui,并将其保留在前台可以正常工作。有没有人知道怎么解决这个问题:非常恼人......

EN

回答 2

Stack Overflow用户

发布于 2012-10-29 00:46:55

这是一段时间以来在resque中的一个大问题在这里查看here

它有点像fork退出时mysql连接消失问题

它关闭了所有it连接,只是这里的区别是不是mysql it redis

因此,简单来说,情况是这样的

代码语言:javascript
复制
#### Resque main worker
redis = Redis.new 
while(true) do 

#### Parent redis connection
redis.blpop(* queue_name)
#### redis queue are polled and message are consumed

#### Resque internally fork to performer the task 

fork {
  #### This fork used the redis connection from the main worker
  #### On exit the fork close the redis connection 
  ##### Perform the background task
}
end

## On Main Worker when the the resque try to use the same connection that was closed it raise the above error 

如何解决这个问题?

有很多种方法可以解决这个问题

a)更新resque (花了一段时间,但现在补丁更新是resque ),请通过here查看

b)如果您没有查看更新,那么您可以使用resque_hooks来实现这一点,如下所示

代码语言:javascript
复制
Resque.after_fork do 
  Resque.redis.client.reconnect
end

c)升级Redis服务器:-这是完全肯定的,但我不确定Redis 2.4.6的版本,尽管重新连接是通过redis内部实现的(不确定是redis还是redis客户端,但我认为重新连接是隐式发生的)

希望这对你有所帮助

票数 0
EN

Stack Overflow用户

发布于 2014-11-25 15:54:33

尝试识别resque进程id,终止它,然后重新启动resque服务器。

此外,您还可以尝试以下方法

代码语言:javascript
复制
Redis.current.client.reconnect
$redis = Redis.current
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12630714

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档