mysqlplus 是比 ruby​​ mysql 更好的适配器吗?

发布于 2024-08-13 12:48:01 字数 295 浏览 3 评论 0原文

我想知道 mysqlplus gem 是否是比常见的 Ruby mysql 宝石?我的 Rails 应用程序曾经遇到过一些问题,例如: ActiveRecord::StatementInvalid: Mysql::Error: MySQL 服务器已消失

I want to know if the mysqlplus gem is a better database driver than the common Ruby mysql gem? I used to have some problems in my Rails application, like:
ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has gone away

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

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

发布评论

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

评论(3

旧城空念 2024-08-20 12:48:01

MySQL 服务器已经消失 意味着 mysql 服务器在运行您的查询时崩溃了,或者(更常见的是)您向其发送了大于 max_allowed_pa​​cket 的查询。参见http://dev.mysql.com/doc /refman/5.1/en/packet-too-large.html

MySQL server has gone away means either the mysql server has crashed running your query or (more commonly) you sent it a quert that is larger than max_allowed_packet. see http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

我爱人 2024-08-20 12:48:01

如果您只想检查“mysql 服务器已消失”错误,那么 activerecord 就足够了。它是一个成熟的代码库,足以满足大多数用例。

签出 http ://blog.new-bamboo.co.uk/2010/4/11/automatic-reconnection-of-mysql-connections-in-active-record 了解更多详细信息。

当您需要并发时,mysqlplus 会更好,所有酷男孩都推荐它:-)
但我不确定它是否已准备好生产。

if you want to only check for 'mysql server has gone away' errors then activerecord is more than sufficient. it is a mature codebase, good enough for most usecases.

checkout http://blog.new-bamboo.co.uk/2010/4/11/automatic-reconnection-of-mysql-connections-in-active-record for more details.

mysqlplus is better when you need concurrency, all the cool boys recommend it :-)
but i am not sure if it is production ready.

我要还你自由 2024-08-20 12:48:01

mysql 在一段时间不活动后获取连接。这是在“wait_timeout”中定义的。
可以通过以下方式在 mysql 中看到这一点:
mysql>显示“wait_timeout”等变量,

默认为 8 小时。您收到此错误是因为您已经建立了连接,并且在此期间没有通过该连接执行任何查询。

Activerecord 有 ActiveRecord::Base#verify_active_connections!对于这个用例。
如果您在database.yml中指定reconnect: true,它将自动执行此操作。

当我们从连接池中检出连接时,会执行上述方法,它可以防止不活动。

如果你正在运行一个长时间运行的查询并且它超过了 wait_timeout 期限,那么你可能必须增加 mysql 中的超时变量。您也可以尝试将补丁设置为:
http://gist.github.com/238999 这将重试此类错误、情况的查询可能已更改,但补丁并不可靠,因为它没有重试计数。

mysql reaps the connections after a period of inactivity. this is defined in 'wait_timeout'.
Can see this in mysql by:
mysql> show variables like 'wait_timeout'

by default it is 8 hours. you are getting this error as you have established a connection and there have been no queries executed over this connection for this period.

Activerecord has ActiveRecord::Base#verify_active_connections! for this usecase.
if you specify reconnect: true in database.yml it will do this automatically.

The above method is executed when we checkout a connection from the connection-pool, it guards against inactivity.

It will not help you if you are running a long-running query and it exceeds the wait_timeout period, Then you may have to increase the timeout variable in mysql. You may also try setting the patch in:
http://gist.github.com/238999 This will retry the query on such a error, circumstances may have changed, but the patch is not robust as it does not have a retry count.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文