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

Suspicious nested transaction behaviour code #3334

Open
sdedic opened this issue Feb 28, 2025 · 1 comment
Open

Suspicious nested transaction behaviour code #3334

sdedic opened this issue Feb 28, 2025 · 1 comment

Comments

@sdedic
Copy link

sdedic commented Feb 28, 2025

Expected Behavior

A @Transactional(propagation = Transactional.Propagation.NESTED) should create a new transaction, if there's an existing one, according to the documentation of NESTED:

Execute within a nested transaction if a current transaction exists

Actual Behaviour

The existing transaction seems to be reused. See the relevant code in AbstractTransactionOperations

Steps To Reproduce

  1. checkout demo app from https://github.com/sdedic/micronaut-dbbugs1
  2. checkout branch nested-transaction
  3. place a breakpoint on line in AbstractTransactionOperations
  4. execute the application with parameter -3

No nested transaction is opened. Transaction closes with the outermost one.

Environment Information

  • Ubuntu 22.04
  • JDK 21

Example Application

No response

Version

4.7.6

@dstepanov
Copy link
Contributor

It should create a new nested TX if one exists. Nested TX is pretty much just using snapshots.

Not every TX managers support nested TXs.

Execute within a nested transaction if a current transaction exists,
         * behave like {@link Propagation#REQUIRED} otherwise. There is no
         * analogous feature in EJB.
         * <p><b>NOTE:</b> Actual creation of a nested transaction will only work on
         * specific transaction managers. Out of the box, this only applies to JDBC
         * when working on a JDBC 3.0 driver. Some JTA providers might support
         * nested transactions as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants