第1部分:Rails/Paperclip/S3神秘错误:undefined method "global_endpoint?"
自从将应用程序从3.0升级到Rails 4.0并同时通过Linode最新的免费RAM升级运行其VPS以来,它一直随机抛出无意义的异常。
像这样的东西:
TypeError: wrong argument type Time (expected time)
/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/transaction.rb:165 in "to_f"
/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/transaction.rb:165 in "stop"
/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/instrumentation/middleware_tracing.rb:63 in "call"
/gems/warden-1.2.3/lib/warden/manager.rb:35 in "block in call"
/gems/warden-1.2.3/lib/warden/manager.rb:34 in "catch"
/gems/warden-1.2.3/lib/warden/manager.rb:34 in "call"
/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57 in "call"
/gems/rack-1.5.2/lib/rack/etag.rb:23 in "call"
/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57 in "call"
/gems/rack-1.5.2/lib/rack/conditionalget.rb:25 in "call"
...
TypeError: wrong argument type Object (expected barrier)
/gems/devise-3.1.0/lib/devise/hooks/forgetable.rb:7 in "block in <top (required)>"
/gems/warden-1.2.3/lib/warden/hooks.rb:14 in "call"
/gems/warden-1.2.3/lib/warden/hooks.rb:14 in "block in _run_callbacks"
/gems/warden-1.2.3/lib/warden/hooks.rb:9 in "each"
/gems/warden-1.2.3/lib/warden/hooks.rb:9 in "_run_callbacks"
/gems/warden-1.2.3/lib/warden/manager.rb:53 in "_run_callbacks"
/gems/warden-1.2.3/lib/warden/proxy.rb:262 in "block in logout"
/gems/warden-1.2.3/lib/warden/proxy.rb:260 in "each"
/gems/warden-1.2.3/lib/warden/proxy.rb:260 in "logout"
/gems/devise-3.1.0/lib/devise/controllers/helpers.rb:155 in "sign_out"
/app/controllers/user_sessions_controller.rb:76 in "destroy"
/gems/actionpack-4.0.8/lib/action_controller/metal/implicit_render.rb:4 in "send_action"
...
NoMethodError: undefined method `_client' for <AWS::Core::Configuration>:AWS::Core::Configuration
/gems/aws-sdk-1.46.0/lib/aws/core/service_interface.rb:73 in "initialize"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:239 in "new"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:239 in "obtain_s3_instance_for"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:233 in "s3_interface"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:243 in "s3_bucket"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:247 in "s3_object"
/app/models/streaming_resource.rb:49 in "block in download_url"
/app/models/retryable.rb:13 in "call"
/app/models/retryable.rb:13 in "retry_this"
/app/models/streaming_resource.rb:48 in "download_url"
/app/views/streaming_resources/_sidebar_item.html.haml:47 in "_app_views_streaming_resources__sidebar_item_html_haml___57519138038974311_58831540"
/gems/actionpack-4.0.8/lib/action_view/template.rb:143 in "block in render"
/gems/activesupport-4.0.8/lib/active_support/notifications.rb:159 in "block in instrument"
...
NoMethodError: undefined method `key?' for nil:NilClass
/gems/activerecord-4.0.8/lib/active_record/core.rb:439 in "init_internals"
/gems/activerecord-4.0.8/lib/active_record/core.rb:206 in "init_with"
/gems/activerecord-4.0.8/lib/active_record/persistence.rb:52 in "instantiate"
/gems/activerecord-4.0.8/lib/active_record/querying.rb:45 in "block in find_by_sql"
/gems/activerecord-4.0.8/lib/active_record/result.rb:21 in "block in each"
/gems/activerecord-4.0.8/lib/active_record/result.rb:21 in "each"
/gems/activerecord-4.0.8/lib/active_record/result.rb:21 in "each"
/gems/activerecord-4.0.8/lib/active_record/querying.rb:45 in "map"
/gems/activerecord-4.0.8/lib/active_record/querying.rb:45 in "find_by_sql"
/gems/activerecord-4.0.8/lib/active_record/relation.rb:587 in "exec_queries"
/gems/activerecord-4.0.8/lib/active_record/relation.rb:471 in "load"
/gems/activerecord-4.0.8/lib/active_record/relation.rb:220 in "to_a"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:80 in "block in associated_records_by_owner"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:80 in "each"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:80 in "each_slice"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:80 in "each"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:80 in "map"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:80 in "associated_records_by_owner"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/collection_association.rb:13 in "preload"
/gems/activerecord-4.0.8/lib/active_record/associations/preloader/association.rb:19 in "run"
...
NoMethodError: undefined method `active=' for nil:NilClass
/gems/haml-4.1.0.beta.1/lib/haml/helpers.rb:91 in "ensure in non_haml"
/gems/haml-4.1.0.beta.1/lib/haml/helpers.rb:91 in "non_haml"
/gems/haml-4.1.0.beta.1/lib/haml/helpers/action_view_mods.rb:10 in "render_with_haml"
/app/views/layouts/lessons.html.haml:8 in "_app_views_layouts_lessons_html_haml___660540921921171033_52318960"
/gems/actionpack-4.0.8/lib/action_view/template.rb:143 in "block in render"
/gems/activesupport-4.0.8/lib/active_support/notifications.rb:159 in "block in instrument"
/gems/activesupport-4.0.8/lib/active_support/notifications/instrumenter.rb:20 in "instrument"
/gems/activesupport-4.0.8/lib/active_support/notifications.rb:159 in "instrument"
/gems/actionpack-4.0.8/lib/action_view/template.rb:141 in "render"
/gems/actionpack-4.0.8/lib/action_view/renderer/template_renderer.rb:61 in "render_with_layout"
/gems/actionpack-4.0.8/lib/action_view/renderer/template_renderer.rb:47 in "render_template"
/gems/actionpack-4.0.8/lib/action_view/renderer/template_renderer.rb:17 in "render"
/gems/actionpack-4.0.8/lib/action_view/renderer/renderer.rb:42 in "render_template"
/gems/actionpack-4.0.8/lib/action_view/renderer/renderer.rb:23 in "render"
/gems/actionpack-4.0.8/lib/abstract_controller/rendering.rb:127 in "_render_template"
/gems/actionpack-4.0.8/lib/action_controller/metal/streaming.rb:219 in "_render_template"
...
ArgumentError: 'false' is not an ActiveModel-compatible object. It must implement :to_partial_path.
/gems/actionpack-4.0.5/lib/action_view/renderer/partial_renderer.rb:436 in "partial_path"
/gems/actionpack-4.0.5/lib/action_view/renderer/partial_renderer.rb:345 in "setup"
/gems/actionpack-4.0.5/lib/action_view/renderer/partial_renderer.rb:262 in "render"
/gems/actionpack-4.0.5/lib/action_view/renderer/renderer.rb:47 in "render_partial"
/gems/actionpack-4.0.5/lib/action_view/helpers/rendering_helper.rb:27 in "render"
/gems/haml-4.1.0.beta.1/lib/haml/helpers/action_view_mods.rb:10 in "block in render_with_haml"
/gems/haml-4.1.0.beta.1/lib/haml/helpers.rb:89 in "non_haml"
/gems/haml-4.1.0.beta.1/lib/haml/helpers/action_view_mods.rb:10 in "render_with_haml"
/app/views/streaming_resources/_sidebar.html.haml:8 in "block in _app_views_streaming_resources__sidebar_html_haml___2619518895430049510_59147280"
/gems/activerecord-4.0.5/lib/active_record/relation/delegation.rb:13 in "each"
/gems/activerecord-4.0.5/lib/active_record/relation/delegation.rb:13 in "each"
/app/views/streaming_resources/_sidebar.html.haml:7 in "_app_views_streaming_resources__sidebar_html_haml___2619518895430049510_59147280"
/gems/actionpack-4.0.5/lib/action_view/template.rb:143 in "block in render"
/gems/activesupport-4.0.5/lib/active_support/notifications.rb:159 in "block in instrument"
/gems/activesupport-4.0.5/lib/active_support/notifications/instrumenter.rb:20 in "instrument"
/gems/activesupport-4.0.5/lib/active_support/notifications.rb:159 in "instrument"
...
这些错误以前从未发生过,也从未在开发或登台环境中发生过。我无法重新创造它们。有一半的时间它们会出现在模型的#show视图上,但然后重新加载页面就可以了。可能每10 - 100次浏览中就会出现一次。
我不知道如何继续或调试。什么好主意吗?
解决了!只花了一年半的时间寻找!事实证明,这与libxml-ruby gem中的一些糟糕的内存挂钩有关。在这里看到的:
https://github.com/sparklemotion/nokogiri/issues/881https://github.com/sparklemotion/nokogiri/issues/1364
从我的Gemfile中删除libxml-ruby修复了它