Skip to content
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

几个小问题,希望跟作者交流一下。 #7

Open
276509842 opened this issue Jun 20, 2017 · 2 comments
Open

几个小问题,希望跟作者交流一下。 #7

276509842 opened this issue Jun 20, 2017 · 2 comments

Comments

@276509842
Copy link

1、测试发现,DataSourceProxy.java 中调用链如下:
-- method: getAutoCommit
-- method: getTargetConnection
----getTargetConnection---true | 4
-- method: prepareStatement

getAutoCommit 和 getTransactionIsolation 方法,因为没有默认值(没注入)
均会调用下面的getTargetConnection 方法,来先占用一个write(默认,还没到mapper拦截器)的connection

导致写库连接不能被回收。

2、RWManagedTransaction 中的commit,直接对writeCon和readCon 执行commit方法,当方法不配置事务时,connection是autoCommit的,执行会报异常,但是被catch住了。

3、insert.selectKey会被路由到从库 (select类型)
RWPlugin.java
if (mappedStatement.getSqlCommandType() == SqlCommandType.SELECT
&& !mappedStatement.getId().endsWith("!selectKey")) {
key = ConnectionHold.READ;
}

4、建议:
是否考虑抽取一个数据源(目前是用的tomcat jdbc), spring-boot的默认配置,支持type来制定数据源

@chenlei2
Copy link
Owner

1、默认调用的一个write链接,关闭链接的时候,会释放链接
2、第二个问题我线下测试一下
3、第三个问题确实考虑不全,非常感谢你指出。
4、第四个建议非常棒,可以参考springboot对数据源type的实现。

你提出的几个问题都非常有参考价值,非常感谢你的意见。后期会考虑根据不同的规则写mybatis插件实现简单分表逻辑,如果感兴趣,可以一起参与。

@276509842
Copy link
Author

可以加个QQ:276509842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants