Re: Problems with extra N+1 requests - likely due to poor mapping defns, but not sure how to rectify


ebenzacar@...
 

I've tried to add the extension definition to my package jdo file but either it isn't working as I expect, or I've defined it incorrectly.  This is what I added:

<field name="addPerson" column="ADDPERSON" default-fetch-group="true">
<extension vendor-name="datanucleus" key="fetch-fk-only" value="true"/>
</field>

With this definition, I was expecting that the object retrieval would basically retrieve the FK value for addPerson from my Manufacturer object.  However, it seems to be trying to retrieve the full object, and puts itself in an endless loop for some reason, causing a StackOverflow.  The datamodel isn't exactly what I listed above, but rather has a bit of a circular design (ie: the AuditPerson actually contains an instance of Audit).   When trying to debug the issue further, I see that DN is calling `dnReplaceFields()` method on my Manufacturer object, but it is difficult to identify which field it is.   I can see the field index value which is causing the endless loop, but can't determine which fieldname the index maps to.  I cannot find the metadata/mapping information where the fieldname is mapped to the field number.  In my case, when I put the debugger on the dnReplaceField in the call stack, I see that it is trying to load field 56, and that this field is causing the infinite loop.  How/where can I identify which fieldname field 56 is mapped to?

Similarly, the DN logs show me what I think is a list of fields that are loaded/not loaded when the object is retreived from cache (loadedFlags) (ex: (id="zzzz" taken from Level 1 cache (loadedFlags="[YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNNNNNNNNNNN]").  But how do I identify which index is which field?





I would have expected that setting datanucleus.maxFetchDepth=1 would prevent any recursion from happening, but it is still endlessly trying to reload that same field #56.

Removing the `addPerson/modPerson` from the default-fetch-group stops the infinite loop.

Any suggestions what/how to investigate next would be appreciated.

Thanks,

Eric



Join main@datanucleus.groups.io to automatically receive all group messages.