Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions in parallel.map on database write #20

Closed
sreid99 opened this issue Oct 4, 2011 · 1 comment
Closed

Exceptions in parallel.map on database write #20

sreid99 opened this issue Oct 4, 2011 · 1 comment

Comments

@sreid99
Copy link

sreid99 commented Oct 4, 2011

I'm getting exceptions in parallel.map threads when I save a record to postgresql. Most of the time it works ok, but sometimes I get an exception (not always the same one) such as below. Not sure if it's an issue with parallels, ruby, postgresql or Passenger/REE.
I use Rails 3.1.1rc2, ruby 1.8.7 on Passenger/REE.

    uninitialized constant ActiveRecord::Associations::JoinDependency::JoinBase

    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/associations/join_dependency.rb:13:in `initialize'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/relation/finder_methods.rb:219:in `new'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/relation/finder_methods.rb:219:in `construct_join_dependency_for_association_find'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/relation/finder_methods.rb:192:in `exists?'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations/uniqueness.rb:33:in `validate_each'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validator.rb:153:in `validate'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validator.rb:150:in `each'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validator.rb:150:in `validate'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:302:in `send'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:302:in `_callback_before_375'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:449:in `_run_validate_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `send'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations.rb:212:in `run_validations!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:390:in `_run_validation_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `send'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations.rb:179:in `valid?'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations.rb:69:in `valid?'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations/associated.rb:5:in `validate_each'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations/associated.rb:5:in `collect'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations/associated.rb:5:in `validate_each'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validator.rb:153:in `validate'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validator.rb:150:in `each'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validator.rb:150:in `validate'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:302:in `send'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:302:in `_callback_before_411'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:449:in `_run_validate_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `send'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations.rb:212:in `run_validations!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:390:in `_run_validation_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `send'
    /home/aaa/shared/bundle/ruby/1.8/gems/activesupport-3.1.1.rc2/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activemodel-3.1.1.rc2/lib/active_model/validations.rb:179:in `valid?'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations.rb:69:in `valid?'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations.rb:77:in `perform_validations'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations.rb:56:in `save!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/transactions.rb:246:in `save!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/transactions.rb:295:in `with_transaction_returning_status'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/transactions.rb:208:in `transaction'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/transactions.rb:246:in `save!'
    /home/aaa/shared/bundle/ruby/1.8/gems/activerecord-3.1.1.rc2/lib/active_record/validations.rb:41:in `create!'
    /home/aaa.rb:165:in `save' ...
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:260:in `call'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:260:in `call_with_index'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:114:in `work_in_threads'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:107:in `loop'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:107:in `work_in_threads'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:16:in `in_threads'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:15:in `initialize'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:15:in `new'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:15:in `in_threads'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:14:in `times'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:14:in `in_threads'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:105:in `work_in_threads'
    /home/aaa/shared/bundle/ruby/1.8/gems/parallel-0.5.9/lib/parallel.rb:55:in `map'
@grosser
Copy link
Owner

grosser commented Oct 5, 2011

Ive heard that require in threads can lead to ugly exceptions like these, try to load ActiveRecord::Associations::JoinDependency::JoinBase before running the parallel code.

@grosser grosser closed this as completed Dec 9, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants