如何在增加紧急负载的同时解决此错误? "ERROR ThreadError: Attempt to unlock a mutex which is locked by another thread"



我的导轨应用程序使用inherited_resources GEM。我目前正在尝试加快速度,以便能够处理更大的数据集。因此,我(在Bullet Gem的帮助下)向前迈进了急切的加载,这将很有帮助。在selenited_resources中看起来像这样:

def collection
  my_widgets ||= end_of_association_chain.includes(:association_one, :association_two, :association_three, :association_four)
  @widgets = case params[:filter]
                  when nil then my_widgets.all
                  when 'old' then my_widgets.old
                  when 'new' then my_widgets.new
                  end
  @final_collection
end

新代码是.includes(:association_one, :association_two, :association_three, :association_four)

这个简单的更改使我的测试巨大数据库加快了我的加载时间约5次。但是,浏览器会坐在那里,空白。没有什么。随着Chrome Loading图标进行。

当我在终端中杀死服务器时,我会遇到这个相当唯一的错误:

 ERROR ThreadError: Attempt to unlock a mutex which is locked by another thread

底部的回溯。

我已经尝试了此问题的首要答案中讨论的解决方案:如何与Rails 4同时服务请求?,以下内容:

#config/environments/development.rb
config.cache_classes = false
config.eager_load = true
config.allow_concurrency=true

我在这里想念什么?为什么简单地将这些关联添加到急切的加载中,这会大大加快幕后的速度,借给我一个无反应的浏览器?

   /USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/lock/lock.rb:22:iin   /USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/lock/lock.rb:22:in   /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/lock/lock.rb:23:in   /users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/rack/content_length.rb:15:in   /USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/rack/handler/webrick.rb:88:in`service''   /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in   /USERS/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:iin   /users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:iin in start_thread'/users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/rack/handler/webrick.rb:48:iin shutsherdown':nillclass for Nil:Nilclass:Nilclass'(nomethoderror)    来自/USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/rack/server.rb:280:在start in Start'    来自/users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:in    来自/USERS/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:iin    来自/USERS/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:iin'block(2级)开始'    来自/USERS/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:iin    来自/USERS/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:iin'block in Start in Start'    来自/users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:32:In    来自/USERS/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:162:iin开始'    来自/USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/rack/handler/webrick.rb:34:in    来自/users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/rack/server.rb:286:in    来自/USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/server.rb:80:in启动'    来自/users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands/commands_tasks.rb:80:80:80:80:in in`in Server in Server'in Server'    来自/USERS/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands/commands_tasks.rb:75:75:75:In tap'tap'    来自/users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands/commands_tasks.rb:75:75:75:75:IN" Server'    来自/users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands/commands_tasks.rb:39:39:39:39:IN`run_command!''    来自/users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands.rb:17:in''    来自bin/rails:4:in``需要''    来自bin/rails:4:在``''

编辑:我开始怀疑这是否比我的数据集太大而无法为急切的加载而大的线程错误,是否有一个阈值,您急切地加载太多对象,而虽然它在终端中很快加载,浏览器永远坐在那里?

是否可以从Webrick转到Puma?我有一个需要并发请求的应用程序。我得到了您描述的错误:

ERROR ThreadError: Attempt to unlock a mutex which is locked by another thread

切换到PUMA解决了该问题。

相关内容

  • 没有找到相关文章

最新更新