Skip to content

Transaction can't spin off additional, unrelated transactional work via ExecutorService #1508

@lightbody

Description

@lightbody

Expected Behavior

In Micronaut 3, I could write code that would execute in a transactional context and then submit work via an ExecutorService to happen in it's own, separate transaction. Our application makes heavy use of this pattern and it seems reasonable to expect it to work in Micronaut 4.

Instead, in Micronaut 4, it appears that because of ExecutorServiceInstrumenter the context from the initial transaction is dragged into the downstream runnable. The result is when any database work starts (including the attempt to start a new transaction), it fails with an error from Hikari that "the connection is closed".

Actual Behaviour

Two separate transactions are able to execute.

Steps To Reproduce

Run the test in https://github.com/lightbody/micronaut-data-4-tx-issue

Environment Information

No response

Example Application

https://github.com/lightbody/micronaut-data-4-tx-issue

Version

4.x

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions