sciencehistory / chf-sufia

sufia-based hydra app
Other
9 stars 4 forks source link

FileSetAttachedEventJob 'undefined method `title' for nil:NilClass' #270

Closed hackartisan closed 7 years ago

hackartisan commented 7 years ago
Class
 ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper
Arguments
---
job_class: FileSetAttachedEventJob
job_id: 87780af1-8f71-4d42-8900-505a5a8de761
queue_name: event
arguments:
- _aj_globalid: gid://chufia/FileSet/z029p5015
- _aj_globalid: gid://chufia/User/3
locale: en
Exception
NoMethodError
Error
undefined method `title' for nil:NilClass
/opt/sufia-project/shared/bundle/ruby/2.3.0/bundler/gems/sufia-73eaac881de5/app/jobs/file_set_attached_event_job.rb:10:in `action'
/opt/sufia-project/shared/bundle/ruby/2.3.0/bundler/gems/sufia-73eaac881de5/app/jobs/event_job.rb:30:in `event'
/opt/sufia-project/shared/bundle/ruby/2.3.0/bundler/gems/sufia-73eaac881de5/app/jobs/content_event_job.rb:20:in `log_user_event'
/opt/sufia-project/shared/bundle/ruby/2.3.0/bundler/gems/sufia-73eaac881de5/app/jobs/event_job.rb:19:in `perform'
/opt/sufia-project/shared/bundle/ruby/2.3.0/bundler/gems/sufia-73eaac881de5/app/jobs/content_event_job.rb:9:in `perform'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/execution.rb:32:in `block in perform_now'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:117:in `call'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/i18n-0.7.0/lib/i18n.rb:257:in `with_locale'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/translation.rb:7:in `block (2 levels) in <module:Translation>'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:441:in `instance_exec'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:342:in `block in simple'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:497:in `block in around'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/logging.rb:23:in `block (4 levels) in <module:Logging>'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:164:in `block in instrument'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:164:in `instrument'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/logging.rb:22:in `block (3 levels) in <module:Logging>'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/logging.rb:45:in `tag_logger'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/logging.rb:19:in `block (2 levels) in <module:Logging>'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:441:in `instance_exec'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:342:in `block in simple'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:497:in `block in around'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_perform_callbacks'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/execution.rb:31:in `perform_now'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/execution.rb:21:in `execute'
/opt/sufia-project/shared/bundle/ruby/2.3.0/gems/activejob-4.2.7.1/lib/active_job/queue_adapters/resque_adapter.rb:46:in `perform'
hackartisan commented 7 years ago

I believe this is caused by saving a work via its file manager before the background job adding the files to the work has completed.

This should not be possible due to locking.

I suspect the locks aren't being held long enough (note: a lock is released at the end of the block)

more analysis needed.

see: https://github.com/projecthydra/curation_concerns/blob/5ed966284a2123a50e40414e32f1ab64a7738d5b/app/actors/curation_concerns/actors/file_set_actor.rb#L124

also related:

hackartisan commented 7 years ago

This error is a side effect of #316

This is an error in the job that creates the notification ("File X was attached to work Y"). This error occurs when the attach job ran, then the relationship was erased by a form save overwriting the work data, then the job to create the notification of the attachment ran. At that point the notification job asks the fileset who its parent is, but that relationship is gone so it gets nil.

However, you don't always get this error when a relationship has been overwritten. If the notification is created before the relationship is wiped then this job doesn't error out.

Closing in favor it #316