Heroku / Unicorn上的重复导轨错误 - '执行过期',一个ActionView :: Template :: Error

时间:2013-05-24 18:16:08

标签: ruby-on-rails heroku mongoid mlab

我的问题类似于以下内容,但情况稍有不同。

Rails: execution expired on time_zone_select

我的设置是:

  • Rails 3.2.13
  • Unicorn 4.6.2
  • Mongoid 3.0.22
  • 轻便摩托车1.4.2

在Heroku Cedar上运行。 MongoDB托管在MongoLab。

错误分批进行,并且通常由Heroku进程重启来解决。第一个通常是下面的那个:

An ActionView::Template::Error occurred in [controller]#[action]:

 execution expired
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/sockets/connectable.rb:46:in `read'

以下是堆栈跟踪的最高位。如果需要,很乐意添加更多!

vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/sockets/connectable.rb:46:in `read'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/sockets/connectable.rb:46:in `block in read'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/sockets/connectable.rb:118:in `handle_socket_errors'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/sockets/connectable.rb:46:in `read'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:177:in `read_data'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:99:in `block in read'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:202:in `with_connection'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:97:in `read'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/protocol/query.rb:163:in `receive_replies'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:135:in `block in receive_replies'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:134:in `map'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/connection.rb:134:in `receive_replies'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:553:in `block (2 levels) in flush'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:129:in `ensure_connected'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:551:in `block in flush'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:566:in `logging'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:550:in `flush'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:539:in `process'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/node.rb:349:in `query'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/cursor.rb:138:in `block in load_docs'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/session/context.rb:105:in `block in with_node'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/cluster.rb:250:in `with_secondary'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/session/context.rb:104:in `with_node'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/cursor.rb:137:in `load_docs'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/cursor.rb:25:in `each'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/query.rb:76:in `each'
 vendor/bundle/ruby/1.9.1/gems/moped-1.4.2/lib/moped/query.rb:76:in `each'
 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.22/lib/mongoid/contextual/mongo.rb:132:in `block in each'
 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.22/lib/mongoid/contextual/mongo.rb:556:in `selecting'
 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.22/lib/mongoid/contextual/mongo.rb:131:in `each'
 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.22/lib/mongoid/contextual.rb:18:in `each'

Rack :: Timeout设置为10秒(我相信这是我读过的一个缓存教程的建议) - 如果答案是增加超时,那很好。但我想知道这不是一个缓慢的查询问题?这种行为似乎表明它只是一个挂起的Unicorn进程(这就是为什么ps重启似乎可以治愈它)。

任何想法或提示都会非常感激!

2 个答案:

答案 0 :(得分:1)

我建议这是heroku的文件或网络系统的问题。 modped read方法调用'Kernel :: select。选择它的self是一个系统阻塞调用,它将等待IO对象变为可读。在这种情况下,它是与MongoLab建立外部连接的TCP端口。 TCP端口可能有多种原因无法读取。脑海中浮现出网络和文件问题。我怀疑这是一个长时间运行的查询,因为套接字在查询运行期间是可读的,因为select不会阻止脚本执行。如果问题仍然存在,我会考虑远离heroku或者可能是不同网络上的外部数据库。 AWS始终是一个不错的选择,因为它们在盒子(盒子)之间具有非常低的延迟。 HTH

答案 1 :(得分:0)

尝试在您的Gemfile中将ruby版本设置为1.9.3,然后再捆绑,提交和部署