问题
How does R2DBC implement transaction-handling.
As far as I know, JDBC use one connection for one transaction. So in Spring MVC we have the following mapping: 1 request : 1 thread : 1 transaction : 1 connection.
What is the mapping in Webflux with R2DBC? Webflux is reactive, so when we open one transaction, does it use one connection until the end of the transaction? If so, then a transaction is something like a blocking operation because, while the transaction is active no other transaction can reuse the connection in Spring Webflux.
Let's say we define 10 connections in R2DBC and 10 Webflux requests open 10 long transactions. Will all the following Webflux requests wait for ending of one of this 10 transactions or can multiple Webflux requests (with transaction) use one single connection in parallel?
回答1:
R2DBC supports only a single transaction per connection. The primary reason - as far as I'm aware - is that a lot of database systems only support a single transaction per connection, so multiplexing transactions on a single connection is not possible.
来源:https://stackoverflow.com/questions/64729022/connection-reuse-and-transactions-relationship