防止 Mongrel/Mysql Errno::EPIPE 异常

发布于 2024-07-06 06:38:13 字数 379 浏览 5 评论 0原文

我有一个 Rails 应用程序,我很少提供 XML。 这是使用 mongrel 和 mysql 运行的。 我发现,如果我不使用该应用程序超过几个小时,它就会死机并开始抛出 Errno::EPIPE 错误。 mysql 连接似乎因不活动或类似原因而超时。

它可以用“mongrel_rails restart -P /path/to/the/mongrel.pid”重新启动...但这并不是真正的解决方案。 我的合作者希望当他工作时该应用程序就在那里(而我很可能不在身边)。

我的问题是:

  • 我能做些什么来防止这个问题发生? (例如,不要让我超时!!)。
  • 如果失败,是否可以在某处插入一些代码来自动重新建立数据库连接?

I have a rails app that I have serving up XML on an infrequent basis.
This is being run with mongrel and mysql.
I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that the mysql connection get timed out for inactivity or something like that.

It can be restarted with 'mongrel_rails restart -P /path/to/the/mongrel.pid' ... but that's not really a solution.
My collaborator expects the app to be there when he is working on his part (and I am most likely not around).

My question is:

  • What can I do to prevent this problem from occurring in the 1st place? (e.g. don't time me out!!).
  • Failing that, is there some code I can insert somewhere to automatically remake the Db connection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的背包 2024-07-13 06:38:13

这是一个解决方案:

https://boxpanel.blueboxgrp.com/public/ the_vault/index.php/Mongrel_/_MySQL_Timeout

上述解决方案的超时对我来说似乎有点高。 由于连接可以使用的内存量,您不希望数据库超时太低。 如果某个连接是孤立的,您希望它合理地超时(比如不要在一周内超时)。

Here's a solution:

https://boxpanel.blueboxgrp.com/public/the_vault/index.php/Mongrel_/_MySQL_Timeout

The timeouts on the above solution seem a little high to me. You don't want your DB timeouts to be too low, because of the amount of memory a connection can use. If a connection is orphaned, you want it to time out reasonably (like not in one week.)

无悔心 2024-07-13 06:38:13

在其他地方,我也得到了以下建议:

  1. 尝试设置
    config.active_record.verification_timeout 低于任何值
    你的mysql连接超时设置是。

  2. 有一个 gem 可以解决这个问题:mysql_retry_lost_connection

    <预><代码> http://rubyforge.org/projects/zventstools/
    “当您遇到丢失连接错误时重新连接到 MySQL 服务器”。

In other places, I also got the following suggestions:

  1. Try setting
    config.active_record.verification_timeout to something lower than whatever
    your mysql connection timeout setting is.

  2. There's a gem to work around this problem: mysql_retry_lost_connection

     http://rubyforge.org/projects/zventstools/
     "Reconnect to the MySQL server when you hit a lost connection error".
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文