Closed klaus-cicd closed 2 weeks ago
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
JDK Version(required): 1.8
SpringBoot Version(required): 2.4.1
dynamic-datasource-spring-boot-starter Version(required): 4.2.0
druid Version(optional):
程序执行到org.springframework.jdbc.datasource.DataSourceUtils#doGetConnection时发现走到了return conHolder.getConnection();的逻辑,导致拿到了错误的数据源,没有执行com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource#getConnection()的逻辑,这应该和[dynamic-datasource]没有关系,我是想请教这个问题我要如何避免?是因为事务相关的内容吗?
org.springframework.jdbc.datasource.DataSourceUtils#doGetConnection
return conHolder.getConnection();
com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource#getConnection()
Expected Result: conHolder为空,从而执行com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource#getConnection()根据dsKey获取正确的动态数据源
Actual Result: 由于conHolder.getConnection();结果不为dsKey对应的数据源,导致数据源获取错误
If there is an exception,or aop invalid,please attach the exception trace:
Just paste your stack trace here!
Step 1
Step 2
Step 3
事务问题,同一个事务内使用了多个数据源导致在第二个数据源执行时,拿到了事务缓存的第一个数据源对象
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
Enviroment
JDK Version(required): 1.8
SpringBoot Version(required): 2.4.1
dynamic-datasource-spring-boot-starter Version(required): 4.2.0
druid Version(optional):
Describe what happened
程序执行到
org.springframework.jdbc.datasource.DataSourceUtils#doGetConnection
时发现走到了return conHolder.getConnection();
的逻辑,导致拿到了错误的数据源,没有执行com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource#getConnection()
的逻辑,这应该和[dynamic-datasource]没有关系,我是想请教这个问题我要如何避免?是因为事务相关的内容吗?Expected Result: conHolder为空,从而执行
com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource#getConnection()
根据dsKey获取正确的动态数据源Actual Result: 由于conHolder.getConnection();结果不为dsKey对应的数据源,导致数据源获取错误
If there is an exception,or aop invalid,please attach the exception trace:
Steps to reproduce
Step 1
Step 2
Step 3