-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unexpected slave datasource routing result when using Round-robin load-balance algorithm in Mybatis #735
Comments
Please provide version |
我也发现有同样的问题,我的版本号是 sharding-jdbc-spring-boot-starter 2.0.0.M3 |
Could you please provide the problem sample code which based on https://github.com/shardingjdbc/sharding-jdbc-example and put it on github? |
OK,At Weekend. I must BanZhuan today |
@ypg521 Thanks, just remind that don't push any sensitive data or codes into github. |
我不认为 这算一个bug, 只不过在一次的操作内进行了多次 getDataSource, |
Forgive me for not using English |
But The result is always hit a same DB If you have 2 slave DB |
@ypg521 The amount of concurrency is too low |
@shulyLi mybatis在第二次获取connection的时候,使用的是Statement.getConnection(); 我理解的是Statement在第二次获取connection的时候,是不需要getDataSource的; 抱歉我英语不好。 |
@ypg521 说的也对,尽管 不能说是bug 但是在一次 原子查询里就要进行多次的 get 也不太合理 |
@terrymanu @haocao @shulyLi the sample code : https://github.com/ypg521/sharding-jdbc-demo . |
master slave module is coupling with JDBC, we plan to split it from JDBC layer, and will fix this issue at that time. |
Fixed in 3.0.0.M1 |
Round-robin
load-balance algorithm in Mybatis
Round-robin
load-balance algorithm in Mybatis
org.apache.ibatis.executor.statement.PreparedStatementHandler.query

ps.execute(); 会调用一次 MasterSlaveLoadBalanceAlgorithm.getDataSource
这是函数调用栈

return resultSetHandler. handleResultSets(ps); 也会调用 MasterSlaveLoadBalanceAlgorithm.getDataSource
这是函数调用栈
就是 一次 数据操作 会让 RoundBin 的 计数 增加2
一般都是 用 id & ((1<< x) - 1) 就会 ~~
这问题 怕是修复不了吧~
The text was updated successfully, but these errors were encountered: