Bug #34154

ObjectValidator has exponential growth factor

Added by Kira Backes over 3 years ago. Updated about 3 years ago.

Status:Resolved Start date:2012-02-21
Priority:Must have Due date:
Assigned To:Rens Admiraal % Done:

100%

Category:Validation
Target version:TYPO3 Flow Base Distribution - 1.1
PHP Version: Complexity:
Has patch:No Affected Flow version:Git master

Description

In the onFlush method of the PersistenceManager all objects are validates, this is a problem especially for many connected entities. Look at the times needed:

Validate Insertion Count: 174
onFlush Validation Duration: 9s

Validate Insertion Count: 234
onFlush Validation Duration: 43s

Validate Insertion Count: 246
onFlush Validation Duration: 129s

At about 300 entities this is already taking hours to validate, so the system is completely unusable.


Related issues

related to TYPO3.Flow - Bug #37363: PersistenceManager->validateObject() ==> to many calls/lo... Resolved 2012-05-21
duplicated by TYPO3.Flow - Bug #34408: CollectionValidator goes in endless recursion Closed 2012-02-29

Associated revisions

Revision 91a9590f
Added by Rens Admiraal over 3 years ago

[TASK] Remove collection validation from Lazy collections

The change to validate collections introduced unwanted behavior
by validating lazy annotated and not yet initialized collections.
This basically disables lazy loading and introduces a major memory
problem.

Change-Id: Ib317803eba7d6ed04b067238e12b45698b6b0485
Related: #34154
Releases: 1.1

Revision 26e4b3fa
Added by Karsten Dambekalns about 3 years ago

[BUGFIX] Avoid validating instances more often than needed

The GenericObjectValidator uses a static variable to store objects being
validated. Objects were still validated over and over because at the
end of isValid() they were detached again.

This change replaces that detach() call with another concept. Now
any validator implementing the new ObjectValidatorInterface can be
given an SplObjectStorage to keep track of instances already
validated.

If you reset that container when it makes sense (before you
actively validate objects) you can avoid validating single instances
more than once in one validation run but still validate at various
points on your logic flow.

If you have implemented your own object validator you should
implement the new ObjectValidatorInterface - the easiest way is
to extend the GenericObjectValidator, if you haven't done that
so far.

Change-Id: I7f437207e27593425b1fbdfc340a442e685a317f
Fixes: #37363
Related: #34154
Releases: 1.1, 1.2

Revision 632685da
Added by Karsten Dambekalns about 3 years ago

[BUGFIX] Avoid validating instances more often than needed

The GenericObjectValidator uses a static variable to store objects being
validated. Objects were still validated over and over because at the
end of isValid() they were detached again.

This change replaces that detach() call with another concept. Now
any validator implementing the new ObjectValidatorInterface can be
given an SplObjectStorage to keep track of instances already
validated.

If you reset that container when it makes sense (before you
actively validate objects) you can avoid validating single instances
more than once in one validation run but still validate at various
points on your logic flow.

If you have implemented your own object validator you should
implement the new ObjectValidatorInterface - the easiest way is
to extend the GenericObjectValidator, if you haven't done that
so far.

Change-Id: I7f437207e27593425b1fbdfc340a442e685a317f
Fixes: #37363
Related: #34154
Releases: 1.1, 1.2

History

#1 Updated by Kira Backes over 3 years ago

This also happens when loading a single entity with lots of connected entities (even when those entities are connected over 5 proxies, it seems like everything is unfolded)

#2 Updated by Gerrit Code Review over 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9180

#3 Updated by Gerrit Code Review over 3 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9180

#4 Updated by Karsten Dambekalns over 3 years ago

  • Category set to Validation
  • Assigned To set to Rens Admiraal
  • Target version set to 1.1

#5 Updated by Karsten Dambekalns about 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF