Skip to content

Instantly share code, notes, and snippets.

@cjcolvar
Last active December 23, 2015 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjcolvar/6559565 to your computer and use it in GitHub Desktop.
Save cjcolvar/6559565 to your computer and use it in GitHub Desktop.
Avalon test that should work, but leads to infinite loop resulting in tons of requests to solr and fedora and eventually times out.
require 'spec_helper'
describe 'fedora_solr_sync_issues' do
describe 'master files no longer in fedora but still in solr' do
let!(:master_file) {FactoryGirl.create(:master_file)}
after do
ActiveFedora::SolrService.instance.conn.delete_by_id(master_file.pid)
ActiveFedora::SolrService.instance.conn.commit
end
it "should not go into an infinite loop" do
media_object = master_file.mediaobject
master_file.inner_object.delete
media_object.reload
#binding.pry
media_object.parts.should == []
end
end
end
@cjcolvar
Copy link
Author

I've spent a long time digging into this but I'm still not seeing how things are looping. The accessor method for the association is called and when it tries to return the association proxy it has built up it hangs (as it appears to run through the whole process again). It looks like association_proxy#load_target might be getting called in favor of association_collection#load_target which handles and logs ObjectNotFoundError. This error is never getting logged so our code is never getting here. I haven't been able to reproduce this with a similar test in AF.

@cjcolvar
Copy link
Author

I also got output from ruby-prof, but I don't really know how to interpret it. Let me know and I can attach it to this gist.

@cjcolvar
Copy link
Author

Looks like the test won't go into an infinite loop if you take out the logging line here:
https://github.com/projecthydra/active_fedora/blob/master/lib/active_fedora/associations/association_collection.rb#L141

@cjcolvar
Copy link
Author

I'm wondering if the fact that association_collection resets @target to Array.new instead of nil as association_proxy does is the source of any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment