在 Heroku、Cedar 和 Unicorn 上:Getting ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected [英] On Heroku, Cedar, with Unicorn: Getting ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected

查看:35
本文介绍了在 Heroku、Cedar 和 Unicorn 上:Getting ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heroku 支持人员说这与他们在共享数据库上的 libssl 版本有关,但我们在一个专用数据库上的项目中也遇到了它.

Heroku support says this has to do with their version of libssl on shared databases, but we've encountered it on a project that's on a dedicated database, too.

基本上,在我们移至新 Cedar 堆栈且 Unicorn 配置为 3 个工作器的每个项目中,此错误经常发生(更接近于部署后):

Basically this error happens every so often (closer to just after a deploy) on every project we've moved to the new Cedar stack with Unicorn configured to 3 workers:

错误信息:

ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected : SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.at

Where:
some_controller#index
[PROJECT_ROOT]/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.11/lib/active_record/connection_adapters/postgresql_adapter.rb, line 505

heroku 还没有答案,除了等待谁知道我们升级共享数据库服务器需要多长时间*而且我在谷歌上没有找到任何东西.

No answers from heroku yet besides maybe wait who knows how long for us to upgrade our shared database servers* and I haven't found anything on google.

他们还建议这与 unicorn 的 worker 重叠有关,我们应该切换到 Thin,但偶尔出现的错误非常值得(我认为!).我希望有一种方法可以配置 Unicorn 以防止重叠.

They also suggested it has to do with unicorn's workers overlapping and that we should switch to Thin but the performance gain is well worth the occasional error(I think!). I'm hoping there's a way to configure Unicorn to prevent the overlap.

有没有人遇到过这种情况,如果有,你是怎么解决的?谢谢!

Has anyone encountered this, and if so, what have you done to resolve it? Thanks!

*不是他们的原话,而是我在他们回应后的感受.

*not their actual words, just how I felt after their response.

推荐答案

Heroku 支持建议我将此添加到我的 Unicorn 配置中:

Heroku support suggested that I add this to my Unicorn config:

附加到您的config/unicorn.rb:

after_fork do |server, worker|
  if defined?(ActiveRecord::Base)
    ActiveRecord::Base.establish_connection 
  end
end

我添加了它,我们一整天都没有看到一个 PGError: SSL SYSCALL 错误.

I added it and we haven't seen a single PGError: SSL SYSCALL error all day.

这篇关于在 Heroku、Cedar 和 Unicorn 上:Getting ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆