Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

cjcolvar commented Sep 14, 2013

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

This comment has been minimized.

Copy link
Owner Author

cjcolvar commented Sep 14, 2013

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

This comment has been minimized.

Copy link
Owner Author

cjcolvar commented Sep 15, 2013

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

This comment has been minimized.

Copy link
Owner Author

cjcolvar commented Sep 15, 2013

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
You can’t perform that action at this time.