Skip to content

Feat: add a configuration to control maximum exceptions can be collect when processing persistence - #542

Merged
andyjefferson merged 1 commit into
datanucleus:masterfrom
LennonChin:master
Jul 21, 2026
Merged

Feat: add a configuration to control maximum exceptions can be collect when processing persistence#542
andyjefferson merged 1 commit into
datanucleus:masterfrom
LennonChin:master

Conversation

@LennonChin

@LennonChin LennonChin commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This PR adds a parameter to control the maximum number of exceptions that can be caught during persistence operations.

Currently, some operations in PersistenceManager and ExecutionContext iterate 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 is Integer.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

@LennonChin

Copy link
Copy Markdown
Contributor Author

Gently ping @andyjefferson please review this PR.

@andyjefferson andyjefferson added this to the 6.0.12 milestone Jul 21, 2026
@andyjefferson
andyjefferson merged commit 1e94d11 into datanucleus:master Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory spiking when ExecutionContextImpl#retrieveObjects encounter database connections lost

2 participants