Skip to content

Can not rollback transaction in Mono.zip(...) when use several reactive transaction managersΒ #28782

@RomanPilyutik

Description

@RomanPilyutik

Currently in project we have separate configured r2dbc connection factories to different schemas in db.
And have several reactive transaction managers.

We met the next issue: with an open transaction through the first transaction manager, we execute Mono.zip to merge two streams. First one work with first db shema (in opened transaction), the second one - with another db schema and open separate transaction through the second transaction manager. And in case of any runtime exception in first stream we get

Expected Behavior:

rollback both transactions

Actual Behavior:

Second transaction rollbacked, but the first one throw exception on rollback: java.lang.IllegalStateException: Transaction synchronization is not active.

Reason:

Seems like as on exception in the first stream from Mono.zip, the second stream is canceled and clears synchronizations in common TransactionContext. As synchronizations is null then first transaction is failed on rollback.

Example to reproduce can be found here https://github.com/RomanPilyutik/spring-tx-issue. Just run SynchronizaionsApplicationTests.

org.springframework.boot: 2.6.3
kotlin: 1.6.0
reactor-core 3.4.14

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions