-
Couldn't load subscription status.
- Fork 38.8k
Description
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