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

Ensure reactive transaction rollback on commit error #30096

Conversation

simonbasle
Copy link
Contributor

@simonbasle simonbasle commented Mar 9, 2023

This change fixes a situation where error handling was skipped during
processCommit() in case the doCommit() failed. The error handling
was set up via an onErrorResume operator that was nested inside a
then(...), applied to an inner Mono.empty(). As a consequence,
it would never receive an error signal (effectively decoupling the
onErrorResume from the main chain).

This change simply moves the error handling back one level up. It also
simplifies the doCommit code a bit by getting rid of the steps that
artificially introduce a Mono<Object> return type, which is not really
needed.

@simonbasle simonbasle added in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug labels Mar 9, 2023
@simonbasle simonbasle added this to the 6.0.7 milestone Mar 9, 2023
@simonbasle simonbasle requested a review from sdeleuze March 9, 2023 16:17
@simonbasle simonbasle self-assigned this Mar 9, 2023
This change fixes a situation where error handling was skipped during
`processCommit()` in case the `doCommit()` failed. The error handling
was set up via an `onErrorResume` operator that was nested inside a
`then(...)`, applied to an inner `Mono.empty()`. As a consequence,
it would never receive an error signal (effectively decoupling the
onErrorResume from the main chain).

This change simply moves the error handling back one level up. It also
simplifies the `doCommit` code a bit by getting rid of the steps that
artificially introduce a `Mono<Object>` return type, which is not really
needed.

A pre-existing test was missing the fact that the rollback didn't occur,
which is now fixed. Another dedicated test is introduced building upon
the `ReactiveTestTransactionManager` class.

Closes spring-projectsgh-28968
Closes spring-projectsgh-30096
@simonbasle simonbasle force-pushed the 28968-r2dbcRollbackOnCommitError branch from 8abee3d to c27e297 Compare March 9, 2023 17:08
@sdeleuze
Copy link
Contributor

Thanks @mp911de and @simonbasle for fixing this!

@simonbasle simonbasle deleted the 28968-r2dbcRollbackOnCommitError branch March 15, 2023 09:11
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) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants