Ah, so it's the garbage collection that's triggering it. I should have known, given the looping worked for small values. This is good. I can distill the failure down to a single pair of EOs using System.gc() now. This should make it a lot easier to investigate.
public void testNestedECs() { try { EOEditingContext ec = ERXEC.newEditingContext(); Company c = (Company) EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME); c.setName("Name"); ec.saveChanges(); EOEditingContext nested = ERXEC.newEditingContext(ec); Company nestC = c.localInstanceIn(nested); Employee e = (Employee) EOUtilities.createAndInsertInstance(nested, Employee.ENTITY_NAME); e.setFirstName("First"); e.setLastName("Last"); e.setManager(Boolean.FALSE); e.addObjectToBothSidesOfRelationshipWithKey(nestC, Employee.COMPANY_KEY); nested.saveChanges(); ec.saveChanges(); System.gc(); c.delete(); ec.saveChanges(); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } } Thanks Alexis, Ramsey On Jun 11, 2012, at 8:05 PM, Alexis Tual wrote: > Hi Ramsey, > > this bug sounds very familiar... > In your code, ec.setRetainsRegisteredObjects(true) should do the job, but > that eats memory. > > For more details, see > http://lists.apple.com/archives/webobjects-dev/2010/Nov/msg00009.html, Mike > said : > I don't have a patch you can easily apply. The workaround on your > side is to not let the EO in the parent EC garbage collect > (basically, keep a reference to the parent EO around for any EO > that you fault into child EC). > > Good luck on this, > > Alex > > > 2012/6/12 Ramsey Gurley <rgur...@smarthealth.com> > Hi all, > > I have a suspicion that something is wrong with the way nested ECs are > currently working. The errors I see are the result of missing snapshots. The > errors are very sporadic and hard to reproduce. I've managed to distill this > down to a simple test case. If I drop this: > > public void testNestedECs() { > try { > EOEditingContext ec = ERXEC.newEditingContext(); > for(int i = 0; i < 100; i++) { > Company c = (Company) > EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME); > c.setName(UUID.randomUUID().toString()); > ec.saveChanges(); > EOEditingContext nested = ERXEC.newEditingContext(ec); > Company nestC = c.localInstanceIn(nested); > for(int j = 0; j < 10; j++) { > Employee e = (Employee) > EOUtilities.createAndInsertInstance(nested, Employee.ENTITY_NAME); > e.setFirstName(UUID.randomUUID().toString()); > e.setLastName(UUID.randomUUID().toString()); > e.setManager(Boolean.FALSE); > > e.addObjectToBothSidesOfRelationshipWithKey(nestC, Employee.COMPANY_KEY); > nested.saveChanges(); > ec.saveChanges(); > } > c.delete(); > ec.saveChanges(); //Line 78 > } > } catch (Exception e) { > e.printStackTrace(); > Assert.fail(e.getMessage()); > } > } > > into ERXECTest.java, I get fairly reliable failures due to missing snapshots. > > java.lang.IllegalStateException: recordDeleteForObject: > com.webobjects.eoaccess.EODatabaseContext > com.webobjects.eoaccess.EODatabaseContext@489bb457 failed to find a snapshot > for EO with Global ID:_EOIntegralKeyGlobalID[Employee (java.lang.Integer)491] > that has been deleted from > er.extensions.eof.ERXECer.extensions.eof.ERXEC@44581ea2. Cannot delete an > object that has not been fetched from the database > at > com.webobjects.eoaccess.EODatabaseContext.recordDeleteForObject(EODatabaseContext.java:4732) > at > com.webobjects.eoaccess.EODatabaseContext.recordChangesInEditingContext(EODatabaseContext.java:5890) > at > com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:373) > at > com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3192) > at er.extensions.eof.ERXEC._saveChanges(ERXEC.java:1177) > at er.extensions.eof.ERXEC.saveChanges(ERXEC.java:1100) > at er.extensions.eof.ERXECTest.testNestedECs(ERXECTest.java:78) > > If I drop the number of loops down to 10 instead of 100, I don't see the > exceptions. Does anyone see an obvious problem with my test case or perhaps > have ideas about what's going wrong before I begin digging? :-) > > Ramsey > > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/alexis.tual%40gmail.com > > This email sent to alexis.t...@gmail.com > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/ramseygurley%40gmail.com > > This email sent to ramseygur...@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com