micronaut-projects / micronaut-projects/micronaut-data
Suspicious nested transaction behaviour code
- Dominant language
- Java
- Stars
- 482
- Forks
- 229
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 32
Description
### 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](https://github.com/micronaut-projects/micronaut-data/blob/4.11.x/data-tx/src/main/java/io/micronaut/transaction/support/AbstractTransactionOperations.java#L469)
### 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](https://github.com/micronaut-projects/micronaut-data/blob/4.11.x/data-tx/src/main/java/io/micronaut/transaction/support/AbstractTransactionOperations.java#L469)
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
Contributor guide
Research direction
Start with data-tx/src/main/java/io/micronaut/transaction/support/AbstractTransactionOperations.java at line 469. Reproduce the report using the linked demo app on its nested-transaction branch, running it with parameter -3, and inspect whether the existing transaction is reused. Done means NESTED propagation opens a nested transaction when an outer transaction exists and closes at the nested boundary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100