-
-
Notifications
You must be signed in to change notification settings - Fork 72
Reset embedded dirty checking #169
Conversation
Updated GrailsEntityDirtinessStrategy.groovy to also reset dirty embedded objects.
| final associations = persistentEntity.getEmbedded() | ||
| for (Embedded a in associations) { | ||
| final value = a.reader.read(entity) | ||
| resetDirty(value, persister, session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if value is null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the value is null then we do not need to reset $changedProperties on embedded. So, the check at line#81 DirtyCheckingSupport.areEmbeddedDirty(persistentEntity, entity) would return false.
| } | ||
| } catch (IllegalStateException e) { | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug(e.message, e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we swallowing the exception here and logging at debug level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this PR, we are recursively resetting the $changedProperties of embedded objects. In cases where the embedded object is not a PersistentEntity the recursion will break, and IllegalStateException is thrown as:
Either class [grails.gorm.tests.dirtychecking.Address] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
|
@graemerocher @puneetbehl Is there are possibility to get this fix merged into the 6.1.x branch and create a 6.1.13 Release? I am a month or two out from a major system replacement which my team has been working on and we have determined that this issue has become a significant problem as we have begun our Production Readiness Testing with large volumes of data. We used embedded objects throughout our domains. So this issue manifests itself when we discover records with "Version" numbers in the hundreds when they should be 0,1 or 2. The reason for this is because we batch process lots of these records. For each batch a record is only updated once, but because of this issue, on the next batch the prior batch records are updated again. On the next batch the prior 2 batches are updated again. This results in hundreds of thousands of extra UPDATES to the database as we process larger number of batches. Eventually the application grinds to a halt as the number of UPDATES cannot be handled. I do not have the option to upgrade to GORM 7 at this time unfortunately. |
Updated GrailsEntityDirtinessStrategy.groovy to also reset dirty embedded objects.
Fixes apache/grails-data-mapping#1272