-
Notifications
You must be signed in to change notification settings - Fork 132
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
Transaction rollback does not work when using AbstractRoutingConnectionFactory. #794
Comments
If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem. |
@mp911de |
@mp911de |
I still need to investigate what's going on but had not any bandwidth to do so. |
@mp911de (I'm not familiar with English. Please don't misunderstand what I'm saying.) |
Transaction definition flags are propagated to the transaction context after obtaining a connection from a connection factory, therefore, the read only flag isn't evaluated at the time of connection retrieval. Your only chance to apply a routing across connection factories is attaching some contextual information to the coroutine invocation and not rely on Spring's |
@mp911de I think it will help not only me but also many developers. |
Hello, @mp911de. I would like to add some examples that is the current situation with my application. Due to the company policy, i could only share the high-level information here. Below is the setup of my application:
Ever since i started to use the Regardless using
That failure happened to the same code base after i upgraded to Spring Boot 3.x which includes the major upgrade on the R2DBC specification itself. Let's consider this sample codes for illustration, the main point is the usage of the
Even when i changed the controller into something like below, i still got the same error. NOTE: the
To make it more interesting, the same codes above was working fine when i was still using this stack:
@mp911de So, do i need to refactor my codes to a certain extent to make the |
It would be something along the lines of: val routingConnectionFactory: AbstractRoutingConnectionFactory = object : AbstractRoutingConnectionFactory() {
override fun determineCurrentLookupKey(): Mono<Any> {
return Mono.deferContextual(contextView -> Mono.just(contextView.getOrDefault("routing", "primary")))
}
} On the resulting publisher that contains the Database access sequence, you would append something contextual like |
I want to parse SQL to determine a specific shard that will ultimately access the database |
hello
When using AbstractRoutingConnectionFactory, Transaction Rollback does not work.
dependencies :
configuration information
Transaction rollback worked normally when using only the primary connection factory.
When using AbstractRoutingConnectionFactory, the transaction doesn't seem to work properly.
The text was updated successfully, but these errors were encountered: