简体   繁体   English

将Phusion Passenger从3.0.11更新到4.0.10会导致ActiveRecord :: StatementInvalid查询期间与MySQL服务器的连接断开

[英]Update Phusion Passenger from 3.0.11 to 4.0.10 causes ActiveRecord::StatementInvalid Lost connection to MySQL server during query

I'm trying to update a rails application on our production server to ruby 1.9. 我正在尝试将生产服务器上的Rails应用程序更新为ruby 1.9。 We have several production sites, some of which have more critical uptime requirements so it would be really beneficial to update each site one at a time to ensure the least amount of downtime on the more critical sites. 我们有几个生产站点,其中一些生产站点具有更关键的正常运行时间要求,因此一次更新每个站点以确保在更关键的站点上停机时间最少是非常有益的。

Phusion Passenger 4 allows to easily run sites using different ruby versions which would be great functionality for ensuring a staggered transition to 1.9 (and later 2.0). Phusion Passenger 4允许使用不同的ruby版本轻松运行站点,这对于确保交错过渡到1.9(以及以后的2.0)将是一个很好的功能。 Currently the server is working under Apache module Passenger 3.0.11 and using the system ruby-1.8.7-352. 当前,该服务器正在Apache模块Passenger 3.0.11下运行,并使用系统ruby-1.8.7-352。

To start the update I have installed rvm and ruby-1.9.2-p320. 要开始更新,我已经安装了rvm和ruby-1.9.2-p320。 Using the new ruby I install passenger 4.0.10. 使用新的红宝石安装旅客4.0.10。 I then updated the httpd.conf with: 然后,我使用以下命令更新了httpd.conf:

LoadModule passenger_module /path/to/mod_passenger.so
PassengerRoot /path/to/gems/passenger-4.0.10
PassengerDefaultRuby /path/to/ruby-1.9.2-p320/ruby

Then in the site.conf 然后在site.conf中

PassengerRuby /path/to/old/ruby

This means that the sites should be using the system ruby, just as before, and the only thing to be updated is Phusion Passenger. 这意味着站点应该像以前一样使用系统红宝石,唯一需要更新的是Phusion Passenger。 The result is that the production applications have started throwing ActiveRecord::StatementInvalid exceptions maybe once every 3000 requests. 结果是生产应用程序已开始引发ActiveRecord::StatementInvalid异常,可能每3000个请求一次。 The exception rate is obviously higher during high traffic periods. 在繁忙时段,例外率明显更高。 The error is as follows: 错误如下:

Exception Class: ActiveRecord::StatementInvalid
Message: Mysql2::Error: Lost connection to MySQL server during query: SELECT ...

I have example of the error on several pages but mostly on those with "large" sql queries (maybe up to 0.4 second query, 1.7 sec request). 我在几个页面上都有该错误的示例,但大多数页面上都是带有“大” sql查询的错误(可能长达0.4秒的查询,1.7秒的请求)。

I have since restored the httpd.conf with the old passenger and the errors have ceased. 从那以后,我与老乘客恢复了httpd.conf,并且错误停止了。

Can anyone help diagnose the source of the query deaths? 谁能帮助诊断查询死亡原因?

Thanks. 谢谢。

=== Edit 1 === ===编辑1 ===

I've tried adding PassengerSpawnMethod direct to httpd.conf so it now reads: 我尝试过将PassengerSpawnMethod direct添加到httpd.conf中,因此现在显示为:

LoadModule passenger_module /path/to/mod_passenger.so
PassengerRoot /path/to/gems/passenger-4.0.10
PassengerDefaultRuby /path/to/ruby-1.9.2-p320/ruby
PassengerSpawnMethod direct

but still have the same error occurring with seemingly the same frequency. 但看似相同的频率仍然会发生相同的错误。

=== Edit 2 === ===编辑2 ===

I've also tried out of desperation installing passenger 4.0.10 under the system 1.8 ruby with the same results. 我还尝试了绝望地在系统1.8 ruby​​下安装乘客4.0.10,结果相同。 Is there anything more I can do or should I just assume passenger isn't ready to be updated? 我还能做些什么吗?还是应该假设乘客还没有准备好进行更新? Is there anything I can look for in my code that could be causing this? 我有什么可以在我的代码中寻找可能导致这种情况的东西吗? I've checked mysql error logs and there's nothing. 我已经检查了mysql错误日志,什么也没有。 Can anyone suggest anything else worth looking at? 任何人都可以提出其他值得一看的建议吗? As for moving forward I'm not planning to spend much more time on this, I'll be testing the production site under ruby 1.9 over weekends and just bite the bullet and move them all over under passenger 3. 至于前进,我不打算在此上花费更多的时间,我将在周末在ruby 1.9下测试生产现场,只需咬一下子弹,将它们移到乘客3下。

=== Edit 3 === ===编辑3 ===

I've now setup passenger so there is only one passenger process for each application under passenger 4. There are still these errors! 我现在已经设置了旅客,因此在旅客4下,每个应用程序只有一个旅客流程。仍然存在这些错误! So not a spawning/multiple access problem. 因此,不是产卵/多路访问问题。 I can't see passenger messing with the application connection to the db but passenger is the only thing I'm changing. 我看不到乘客弄乱了与数据库的应用程序连接,但乘客是我唯一要更改的东西。 I'm using the standard msyql2 gem for my rails app. 我在Rails应用程序中使用标准的msyql2 gem。 The requests that are failing are largish select queries (on the order of a second to complete). 失败的请求是较大的选择查询(大约需要一秒钟完成)。

Having updated my apps to ruby 1.9 the errors have ceased. 将我的应用程序更新为ruby 1.9后,错误停止了。 I never found out what was causing them but I wanted to answer here in case anyone else runs into the same problem. 我从未发现是什么原因造成的,但是我想在这里回答,以防其他人遇到相同的问题。

I had the same issue, but not with phusion. 我遇到了同样的问题,但是却不满意。 Turned out these "larger" queries were being killed by the ActiveRecord connection pool reaper ( reaping_frequency config). 原来,这些“较大”的查询被ActiveRecord连接池收割器( reaping_frequency配置)杀死了。 See: https://stackoverflow.com/a/22423893/72176 参见: https : //stackoverflow.com/a/22423893/72176

Not sure if this is your issue as it seems yours fixed itself, but if others have this error message – that is definitely one avenue to check. 不确定这是否是您的问题,似乎是您自己解决的,但是如果其他人有此错误消息-绝对是检查的一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM