curationexperts / laevigata

A Hyrax-based ETD repository including deposit workflow
Other
5 stars 4 forks source link

Edit or delete committee members leaves orphaned records in fedora #1733

Open val99erie opened 6 years ago

val99erie commented 6 years ago

Steps to reproduce the problem:

cm_attrs = [
  { name: ['Frodo'], affiliation: ['Emory University'] },
  { name: ['Bilbo'], affiliation: ['University of Bilbo'] }
]

cc_attrs = [
  { name: ['Gandalf'], affiliation: ['Emory University'] }
]

etd = Etd.new(title: ['ETD 1'], committee_members_attributes: cm_attrs, committee_chair_attributes: cc_attrs)

etd.save!
etd.committee_members = nil
etd.save!

Expected Result:

The 2 child resources should have been removed from the work's record in fedora.

Actual Result:

The 2 (orphaned) child resources still exist in fedora.

val99erie commented 6 years ago

Here's another clue:

If I try to delete an individual committee member with committee_member.destroy, it returns true, but the committee member didn't actually get deleted.

I stepped through the code and saw a transaction rollback:

I asked @no-reply about it, and he suspects that the parent work's `committee_members` field got updated during the middle of the transaction to update the nested record, so the transaction rolled back.