在Heroku上增加dyno数后的错误

时间:2013-03-10 23:22:47

标签: ruby facebook heroku

我在Heroku服务器上使用Ruby编写了一个Facebook应用程序,一切都很顺利,直到我将dynos的数量增加到2.此时,大约一半的时间我去了一个新的页面,我会得到一条错误消息,或者我将返回主页,具体取决于我去过的页面。我通过回到一个dyno修复了这个问题,但我仍然不知道出了什么问题。有任何想法吗?代码可以在这里找到:

https://github.com/runninggraeb/toolshed

,程序可以在这里找到(如果你有兴趣):

https://apps.facebook.com/toolshed

任何帮助都将不胜感激。

所有日志都粘贴在下面。请注意,在使用dyno = web.1,然后是dyno = web.2。

之后,错误消息开始了
2013-03-10T22:34:54+00:00 heroku[router]: at=info method=GET path=/auth/facebook host=toolshed.herokuapp.com fwd="24.20.19.205" dyno=web.2 queue=0 wait=7ms connect=5ms service=10ms status=302 bytes=0
2013-03-10T22:34:57+00:00 app[web.1]: 24.20.19.205 - - [10/Mar/2013 22:34:57] "GET /auth/facebook/callback?code=AQC7B6vjC0ksefFLly76DMeqL-hHrR6M49lYgMqiAk01xmF-nbXC9pOAcd_e5x8KTycXcjfXG_ABRUmsfeQlusGECbL7d4PqF-nTIVMA1GBn8hAemVCBKXy8sUspQ1eIZAxICtYeSUk9DzM8-It9-AAbi0FudCRS8PkcTaZ-8SXnNYRk2-iYKMin_fYUG2kT8LbApmaeb1RjtxXQUF8HbvAu HTTP/1.1" 302 - 0.0724
2013-03-10T22:34:57+00:00 app[web.1]: 24.20.19.205 - - [10/Mar/2013 22:34:57] "GET / HTTP/1.1" 200 6836 0.2166
2013-03-10T22:34:57+00:00 heroku[router]: at=info method=GET path=/ host=toolshed.herokuapp.com fwd="24.20.19.205" dyno=web.1 queue=0 wait=9ms connect=15ms service=235ms status=200 bytes=6836
2013-03-10T22:35:01+00:00 app[web.2]: NoMethodError - undefined method `length' for nil:NilClass:
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:708:in `block (2 levels) in route!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:755:in `catch'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:755:in `process_route'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:758:in `block in process_route'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `block in invoke'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:in `block in perform_action_with_newrelic_trace'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `catch'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:644:in `block in call!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `invoke'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:808:in `instance_eval'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/app.rb:86:in `block in <top (required)>'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1152:in `block in compile!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:724:in `instance_eval'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:706:in `each'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:706:in `route!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:724:in `route_eval'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:843:in `dispatch!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/head.rb:9:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/sinatra.rb:48:in `block in dispatch_with_newrelic'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/sinatra.rb:47:in `dispatch_with_newrelic'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1303:in `synchronize'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.4.33/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in `perform_action_with_newrelic_trace'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:707:in `block in route!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:84:in `block in pre_process'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1272:in `block in call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/commonlogger.rb:20:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:644:in `call!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:629:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/session/abstract/id.rb:190:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/methodoverride.rb:24:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.2.6/lib/sinatra/base.rb:1272:in `call'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/controllers/controller.rb:86:in `start'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/runner.rb:185:in `run_command'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.2/lib/rack/session/abstract/id.rb:195:in `context'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/runner.rb:151:in `run!'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
2013-03-10T22:35:01+00:00 app[web.2]:  /app/vendor/bundle/ruby/1.9.1/gems/thin-1.2.11/bin/thin:6:in `<top (required)>'
2013-03-10T22:35:01+00:00 app[web.2]: 24.20.19.205 - - [10/Mar/2013 22:35:01] "GET /friends_tools.html HTTP/1.1" 500 30 0.1515
2013-03-10T22:35:01+00:00 heroku[router]: at=info method=GET path=/friends_tools.html host=toolshed.herokuapp.com fwd="24.20.19.205" dyno=web.2 queue=0 wait=0ms connect=4ms service=156ms status=500 bytes=30

1 个答案:

答案 0 :(得分:0)

这个问题只会在超过一个dyno时进行裁剪,这表明它可能是一个共享状态问题。即用户在dyno-1上进行身份验证,session-id被存储在dyno-1的内存中。同一用户的下一个请求是dyno-2的服务器,它不知道会话并且爆炸。这是纯粹的猜想,我没有检查过你的代码。

或者,this Sinatra issue与New Relic有类似的错误,并建议升级到New Relic问题的预发布版本可以解决问题。