On Heroku, Cedar, with Unicorn: Getting ActiveRecord::StatementInvalid: PGError: SSL SYSCALL error: EOF detected

匿名 (未验证) 提交于 2019-12-03 02:00:02

问题:

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.

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:

Error Message:

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

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.

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.

回答1:

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

Append to your config/unicorn.rb:

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

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!