2013-03-10 32 views
2

我在Heroku服務器上使用Ruby編寫了一個使用Ruby的Facebook應用程序,並且一切進展順利,直到我將dynos數量增加到2爲止。此時,大約一半的時間到一個新的頁面,我會得到一個錯誤信息,或者我會返回到主頁,這取決於我去了哪個頁面。我通過回到一個測功機來解決這個問題,但我仍然不知道哪裏出了問題。有任何想法嗎?該代碼可以在這裏找到:在Heroku上增加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 
+0

從Heroku粘貼一些錯誤日誌 – catsby 2013-03-11 01:37:06

+0

「NoMethodError - 未定義的方法'長度爲nil:NilClass:」是一個應用程序錯誤。 '3.5.8.72'是New Relic寶石的舊版本。 '捆綁更新newrelic_rpm'並推送它,然後看看你得到了什麼 – catsby 2013-03-11 03:03:58

+0

我試過了,但我仍然得到了同樣的錯誤 - 但是修復好東西。謝謝! – Ryan 2013-03-11 03:30:50

回答

0

,只有縮放超出一個賽道時作物的問題表明,它可能是一個共享的狀態問題的事實。即用戶在dyno-1上進行身份驗證,會話ID在dyno-1上存儲在內存中。同一用戶的下一個請求是服務器由dyno-2服務器,它不知道該會話並炸燬。這是純粹的猜想,我沒有檢查過你的代碼。

或者,this Sinatra issue與New Relic有類似的錯誤,並建議升級到New Relic問題的預發佈版本可以解決問題。

+0

如果用戶身份驗證在dyno- 1和dyno-2,你有什麼建議如何解決這個問題?解決方案是將身份驗證存儲在其他位置,還是與其他dynos一起檢查? – Ryan 2013-03-11 15:03:20

+0

如果問題歸因於共享狀態,那麼您必須確保共享狀態存儲在所有dynos訪問它的地方,即數據庫,共享內存緩存或其他內容。 – friism 2013-03-11 15:27:52