Issue Details (XML | Word | Printable)

Key: NUCCORE-561
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Fernando Padilla
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

findObject should have extension to not validate objects that come from cache

Created: 26/Jul/10 04:44 AM   Updated: 20/Oct/10 09:29 AM   Resolved: 21/Sep/10 12:27 PM
Component/s: Queries
Affects Version/s: None
Fix Version/s: 2.2.0.m2


 Description  « Hide
In our app we have over-ridden the findObject(Object id, boolean validate, boolean checkInheritance, String objectClassName) method, so that it would not actually validate objects that come from the cache. If the cache is maintained properly and trusted, then it should never have an object that does not exist in the database. If that is the case, then re-validating every object from cache is just a huge waste of database resources. :)

We simply changed the "if (validate)" near the bottom of the function to be "if (validate && !fromCache)" and have seen a great performance improvement.

Chris Colman added a comment - 31/Jul/10 03:54 AM
This sounds like an awesome optimization. I suggested something like this a long way back. If your system is running with a single L2 cache then why not trust it rather than the database as all objects and object updates must go through the cache. Maybe that's the problem... object updates... maybe they aren't flushed to the L2 cache yet - but that could be fixed with a cache eviction of updated L2 objects.

Andy Jefferson made changes - 20/Sep/10 01:39 PM
Field Original Value New Value
Project DataNucleus RDBMS [ 10144 ] DataNucleus Core [ 10143 ]
Key NUCRDBMS-439 NUCCORE-561
Andy Jefferson added a comment - 20/Sep/10 01:40 PM
DN does what the spec says, explicitly. If the user requests "validate" then it validates. Obviously this can be a vendor extension, and users can propose a patch

Fernando Padilla added a comment - 20/Sep/10 06:15 PM
I say let bygones be bygones, but please; let's add at least an option to have it work this way. :) Thank you! :)

"assumeCacheValid"

Andy Jefferson made changes - 21/Sep/10 12:25 PM
Summary findObject should not validate objects that come from cache? findObject should have extension to not validate objects that come from cache
Assignee Andy Jefferson [ andy ]
Fix Version/s 2.2.0.m2 [ 11022 ]
Component/s Queries [ 10154 ]
Andy Jefferson added a comment - 21/Sep/10 12:27 PM
Default behaviour will always be strict JDO (at least until we have persistence profiles added). Users can now set the persistence property
datanucleus.findObject.validateWhenCached
(with default of true).

Andy Jefferson made changes - 21/Sep/10 12:27 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Fernando Padilla added a comment - 21/Sep/10 06:35 PM
actually, not sure how to reopen this bug.. but there is a bug in your fix. :) The correct test within ObjectManagerImpl should be, to skip validation only if it's fromCache and performValidation is false.

if (validate && (performValidation || !fromCache))

NOT:

if (validate && performValidation)





Index: core/trunk/src/java/org/datanucleus/ObjectManagerImpl.java
===================================================================
--- core/trunk/src/java/org/datanucleus/ObjectManagerImpl.java (revision 10517)
+++ core/trunk/src/java/org/datanucleus/ObjectManagerImpl.java (revision 10518)
@@ -2766,7 +2766,8 @@
             }
         }
 
- if (validate)
+ boolean performValidation = (omf.getBooleanProperty("datanucleus.findObject.validateWhenCached"));
+ if (validate && performValidation)
         {
             // User requests validation of the instance so go to the datastore to validate it
             // loading any fetchplan fields that are needed in the process.

Andy Jefferson made changes - 20/Oct/10 09:29 AM
Status Resolved [ 5 ] Closed [ 6 ]