You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As this code has proved to be useful in my endeavour to create a master-slave routing for a mysql read replica configuration and having wasted a few hours on trying to understand why after a read transaction, the next write transaction would go to the read replica, I've found a missing link in this code.
Spring, by default (in newer versions) uses handling_mode: IMMEDIATE_ACQUISITION_AND_HOLD which closes a database connection only on session close (therefor going to the read replica database for the next transaction after a read only transaction). In order to solve this, you need to pass the following application property: spring.jpa.properties.hibernate.connection.handling_mode: DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION
I am not creating a PR as this repository seems not maintained anymore, so an issue would be more visible.
The text was updated successfully, but these errors were encountered:
Hey,
As this code has proved to be useful in my endeavour to create a master-slave routing for a mysql read replica configuration and having wasted a few hours on trying to understand why after a read transaction, the next write transaction would go to the read replica, I've found a missing link in this code.
Spring, by default (in newer versions) uses
handling_mode: IMMEDIATE_ACQUISITION_AND_HOLD
which closes a database connection only on session close (therefor going to the read replica database for the next transaction after a read only transaction). In order to solve this, you need to pass the following application property:spring.jpa.properties.hibernate.connection.handling_mode: DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION
I am not creating a PR as this repository seems not maintained anymore, so an issue would be more visible.
The text was updated successfully, but these errors were encountered: