nilbus / pinewood-derby

Pinewood derby status board & sensor driver
Other
17 stars 9 forks source link

Potential deadlock detected in Ruby 2 #17

Closed nilbus closed 9 years ago

nilbus commented 10 years ago

Ruby 2 detects potential deadlocks that earlier versions did not. See https://bugs.ruby-lang.org/issues/7917. The daemon does not run under ruby 2 because of this error.

rake aborted!
can't be called from trap context
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thread_safe-0.1.0/lib/thread_safe/mri_cache_backend.rb:15:in `synchronize'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thread_safe-0.1.0/lib/thread_safe/mri_cache_backend.rb:15:in `[]='
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activesupport/lib/active_support/callbacks.rb:384:in `block in __callback_runner_name_cache'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thread_safe-0.1.0/lib/thread_safe/cache.rb:38:in `call'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thread_safe-0.1.0/lib/thread_safe/cache.rb:38:in `[]'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activesupport/lib/active_support/callbacks.rb:392:in `__callback_runner_name'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activesupport/lib/active_support/callbacks.rb:367:in `__define_callbacks'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activesupport/lib/active_support/callbacks.rb:77:in `run_callbacks'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/core.rb:198:in `init_with'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/persistence.rb:55:in `instantiate'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/querying.rb:47:in `block (2 levels) in find_by_sql'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/result.rb:21:in `block in each'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/result.rb:21:in `each'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/result.rb:21:in `each'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/querying.rb:47:in `map'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/querying.rb:47:in `block in find_by_sql'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/explain.rb:36:in `logging_query_plan'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/querying.rb:37:in `find_by_sql'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/relation.rb:565:in `exec_queries'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/relation.rb:456:in `block in load'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/explain.rb:36:in `logging_query_plan'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/relation.rb:456:in `load'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/relation.rb:197:in `to_a'
/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bundler/gems/rails-5458f509d9a3/activerecord/lib/active_record/relation/delegation.rb:53:in `keep_if'
/Users/nilbus/sync/Dropbox/git/pinewood-derby/app/models/dashboard.rb:22:in `contestant_times'
/Users/nilbus/sync/Dropbox/git/pinewood-derby/app/models/dashboard.rb:10:in `to_json'
/Users/nilbus/sync/Dropbox/git/pinewood-derby/app/models/dashboard.rb:5:in `to_json'
/Users/nilbus/sync/Dropbox/git/pinewood-derby/app/controllers/announce_controller.rb:4:in `update'
/Users/nilbus/sync/Dropbox/git/pinewood-derby/app/controllers/announce_controller.rb:30:in `block in <class:AnnounceController>'

The traceback suggests the issue may be with the old version of rails or threadsafe that we're using.

nilbus commented 10 years ago

The error can also manifest via foreman:

/Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:226:in `synchronize': can't be called from trap context (ThreadError)
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:226:in `output_with_mutex'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:232:in `system'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:305:in `terminate_gracefully'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:41:in `block in start'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:290:in `call'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:290:in `wait2'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:290:in `watch_for_termination'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/engine.rb:48:in `start'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/lib/foreman/cli.rb:40:in `start'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.16.0/lib/thor.rb:275:in `dispatch'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/gems/foreman-0.60.2/bin/foreman:7:in `<top (required)>'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bin/foreman:23:in `load'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bin/foreman:23:in `<main>'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
        from /Users/nilbus/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
nilbus commented 10 years ago

Updating the thread_safe and atomic gems to the latest did not resolve the issue.