Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoTransactionInContextException Reactor Memory Leak (Regression Issue #33601) #34059

Closed
realjenius opened this issue Dec 9, 2024 · 2 comments
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: duplicate A duplicate of another issue type: regression A bug that is also a regression

Comments

@realjenius
Copy link

After upgrading to the latest Spring Boot that includes #33601 we detected a memory leak in our application. The good news is that we discovered we have cases of triggering NoTransactionInContextException (in this case when closeConnection is happening), but unfortunately it introduced new stability issues by regularly running out of memory.

The static exception introduced by the referenced change (to reduce GC pressure) has introduced a hard path to the GC root for assembly checkpoint records which are growing unbounded for our use-case and causing out-of-memory errors.

Reactor uses the suppressed exception as a carrier for the assembly data so checkpoints can provide better assembly traces (See this code).

Because Spring is now using the same exception for every time it throws a NoTransactionInContextException, for code that is regularly failing with this exception, this can result in a persistent growing list of failure checkpoints being captured under a hard GC root.

The path is effectively:

  • TransactionContextManager.<static fields>
    • NoTransactionInContextException
      • suppressed -> OnAssemblyException
        • nodesPerId -> Map<Integer, ObservedAtInformationNode> (unbounded growth happens here)

While I don't have a verified reproducible case at this very moment it should be as simple as:

while (true) {
  Mono.just(true)
    .checkpoint("some-checkpoint-" + System.nanotime())
    .then(Mono.fromCallback(() -> /* do something against a DB without a transaction that results in the no context exception */)
    .subscribe();
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 9, 2024
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 10, 2024
@jhoeller jhoeller added this to the 6.2.1 milestone Dec 10, 2024
@jhoeller
Copy link
Contributor

jhoeller commented Dec 10, 2024

In any case, we'll fix this for 6.2.1.

@jhoeller jhoeller closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@jhoeller jhoeller removed this from the 6.2.1 milestone Dec 10, 2024
@sbrannen sbrannen added the status: duplicate A duplicate of another issue label Dec 10, 2024
@realjenius
Copy link
Author

In any case, we'll fix this for 6.2.1.

Not sure why I didn't see the dupe, but thank you much for the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: duplicate A duplicate of another issue type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants