使用Resque在Heroku上的Postgres错误 [英] Postgres error on Heroku with Resque
问题描述
我对Postgres的了解不足,无法理解消息。
PG :: Error:SSL错误:解密失败或错误的记录mac:从pg_attribute中选择一个a.attname,format_type(a.atttypid,a.atttypmod),d.adsrc,a.attnotnull在哪里a.attrelid ='用户':: regclass和a.attnum> 0并且不是a.attisdropped OR.A.attnum
这是来自resque后端的调用栈
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters /postgresql_adapter.rb:1139:in`async_exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1139:in` exec_no_cache'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in exec_query中的块
/ app / vendor / bundle / ruby / 1.9.1 / gems / activerecord-3.2.2 / lib / active_record / connection_adapters / abstract_adapter.rb:280:in`log in log'
/ app / vendor / bundle / ruby /1.9.1/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in`instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord- 3.2.2 / lib / active_record / connection_adapters / abstract_adapter.rb:275:在`log'
/ app / vendor / bu中ndle / ruby / 1.9.1 / gems / activerecord-3.2.2 / lib / active_record / connection_adapters / postgresql_adapter.rb:662:在exec_query中
/app/vendor/bundle/ruby/1.9.1/gems /activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1264:in`column_definitions'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/ active_record / connection_adapters / postgresql_adapter.rb:858:在'columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/schema_cache.rb:12中:in在'init in block'中
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:在`yield'
中/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:在'default'
/app/vendor/bundle/ruby/1.9中。 1 / gems / activerecord-3.2.2 / lib / active_record / model_schema.rb:228:在'columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib中/active_record/model_schema.rb:237:在`columns_hash'
/ app / ve中ndor / bundle / ruby / 1.9.1 / gems / activerecord-3.2.2 / lib / active_record / relation / delegation.rb:7:in'columns_hash'
/app/vendor/bundle/ruby/1.9.1 /gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:330:in`find_one'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/ lib / active_record / relation / finder_methods.rb:311:在`find_with_ids'中
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb :107:在`find'
中/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/querying.rb:5:在`find'
中/app/app/workers/compute_worker.rb:5:in'perform'
说明:
我的工作人员只在数据库中做一些写操作。没什么复杂的。
当我第一次执行工作者的任务时,它可以工作,而第二次失败时,出现上述消息。
如果我重新启动工作程序,它将仅在第一次工作。
我已经运行
heroku pg:重新启动
heroku db:重新启动
heroku db:迁移
...没有成功。
在我的本地计算机(使用mysql)上,它可以完美运行。知道吗?
感谢 Rails初学者和 mu太短的评论,我找到了解决方案。 / p>
我已将其添加到初始化程序中,并且成功了!
Resque.after_fork = Proc.new {ActiveRecord :: Base。Establishment_connection}
I don't know enough Postgres to understand the message.
PG::Error: SSL error: decryption failed or bad record mac : 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.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum
And here is the callstack got from the resque backend
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1139:in `async_exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1139:in `exec_no_cache'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `block in exec_query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:662:in `exec_query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1264:in `column_definitions'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:858:in `columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `yield'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `default'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:237:in `columns_hash'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/relation/delegation.rb:7:in `columns_hash'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:330:in `find_one'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:311:in `find_with_ids'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/relation/finder_methods.rb:107:in `find'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib/active_record/querying.rb:5:in `find'
/app/app/workers/compute_worker.rb:5:in `perform'
Explanation: My worker is only doing some writing operations into the databases. Nothing complicated. When I execute the worker's task for the first time, it works, and the second time it fails with the above message. If I restart the worker, it will work only the first time. I already run
heroku pg:restart
heroku db:restart
heroku db:migrate
... without success.
On my local computer(using mysql) it works perfectly. Any idea ?
Thanks to the comments of "Rails beginner" and "mu is too short" I found the solution.
I've added this to an initializer and it did the trick!
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
这篇关于使用Resque在Heroku上的Postgres错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!