Feat: add a configuration to control maximum exceptions can be collect when processing persistence - #542
Merged
Conversation
…t when processing persistence
Contributor
Author
|
Gently ping @andyjefferson please review this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a parameter to control the maximum number of exceptions that can be caught during persistence operations.
Currently, some operations in
PersistenceManagerandExecutionContextiterate over the fields of the passed-in objects and capture all exceptions in an ArrayList. In certain scenarios (e.g., lost or disconnected database connections), the iteration process throws exceptions (the iterator's state is not updated due to the exception), and these exceptions are caught by the outer layer, causing the iteration to continue, potentially leading to an infinite loop. Furthermore, storing a large number of exceptions in the ArrayList can cause JVM memory usage to spike, potentially resulting in an OutOfMemoryError.We've added a parameter
datanucleus.persistence.maximumCollectNestedExceptions, which specifies the maximum number of exceptions that can be caught. The default value isInteger.MAX_VALUE, ensuring consistency with existing behavior. Users can configure this parameter, with a minimum value of 1. When the number of exceptions thrown during the iteration operation exceeds or equals this value, the iteration operation will be fast-failed quickly to avoid an infinite loop.Also, please note that PR datanucleus/datanucleus-api-jdo#145 uses the newly added parameters.
Fixes #540