My Rails 응용 프로그램에서 inherited_resources
gem을 사용합니다. 나는 현재 훨씬 더 큰 데이터 세트를 처리 할 수 있도록 속도를 높이려고 노력 중이다. 그래서 나는 도움이 될만한 곳에 열심히 로딩을 사용하기 위해 (Bullet gem의 도움으로) 앞으로 나아 갔다. inherited_resources 내에서 그것은 다음과 같은 :열심히로드하는 동안이 오류를 어떻게 해결합니까? "ERROR ThreadError : 다른 스레드에 의해 잠긴 뮤텍스 잠금 해제 시도"
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
새로운 코드는이 간단한 변화가 내 테스트 거대한 데이터베이스에 대한 약 5 배 로그에 내를, loadTime을 가속화 .includes(:association_one, :association_two, :association_three, :association_four)
입니다. 그러나 브라우저는 그냥 비어있게됩니다. 아무것도. 크롬로드 아이콘이 표시됩니다. 하단에
ERROR ThreadError: Attempt to unlock a mutex which is locked by another thread
역 추적 :
내가 터미널에서 서버를 죽일
, 나는이 오히려 독특한 오류가 발생합니다. 이미 해결책이 질문에 맨 대답에서 논의 시도: 내가 여기서 뭘
#config/environments/development.rb
config.cache_classes = false
config.eager_load = true
config.allow_concurrency=true
을 잃었 다음으로, How can I serve requests concurrently with Rails 4?? 왜 이러한 연관을 열심히로드하는 것만으로 간단하게 장면 뒤에있는 것을 빠르게 처리 할 수 있습니까?이 ThreadError가 응답하지 않는 브라우저를 빌려주는 이유는 무엇입니까?
/Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/lock.rb:22:in `unlock' /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/lock.rb:22:in `ensure in call' /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/lock.rb:23:in `call' /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call' /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/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 `service' /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run' /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread' /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:48:in `shutdown': undefined method `shutdown' for nil:NilClass (NoMethodError) from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:280:in `block in start' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:in `call' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:in `join' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:in `block (2 levels) in start' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:in `each' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:206:in `block in start' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:32:in `start' from /Users/johndoeuser/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:162:in `start' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:34:in `run' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:286:in `start' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/server.rb:80:in `start' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:in `block in server' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /Users/johndoeuser/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands.rb:17:in `' from bin/rails:4:in `require' from bin/rails:4:in `'
편집 :이 내 데이터 세트는 열망로드에 대한 너무 큰 것보다 스레드 오류의 작은 경우 궁금해하기 시작하고, 신속로드하는 동안, 당신이 열망로드 많은 객체가 임계 값이 있습니다 터미널에서 브라우저는 영원히 거기에 앉아 있습니다.
테스트를 위해 Unicorn으로 전환 했으므로이 오류가 지금은 발생하지 않았지만 약 5,000 개가 넘는 개체는 여전히 기능 상 남아 있습니다. 내 브라우저가 activerecord 객체를 한 번에로드 할 수있는로드 제한이 있는지 궁금해하기 시작했습니다. – Schwad
이로 인해 오류가 제거되었습니다. 더 큰 문제는 내가 데이터를 제대로 처리하지 못하고 ActiveRecord를 너무 많이 남용하고 있다는 것입니다. – Schwad