nevereverever opened a new issue #4946: To terryManu URL: https://github.com/apache/incubator-shardingsphere/issues/4946 Dear terryManu: I've been using sharding proxy for two months,and try to use it in the project.I reported some questions,some of them were closed before they were solved, and some of them got good feedback.No one will reply to those who have been shut down. I'm here to retell the definite problems I have encountered.Sharding proxy is an excellent open source product, but there are still many problems. I have fixed some bugs in my own project. I hope you can also pay attention to it (1)I use this sharding rule to split my table,but using ""(Double quotation marks) will route to all table node: this is the sharding rule: ```java @Slf4j public class SimpleHashShardingAlgorithm implements PreciseShardingAlgorithm<String> { @Override public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<String> shardingValue) { String columnName = shardingValue.getColumnName(); String tableName = shardingValue.getLogicTableName(); String value = shardingValue.getValue(); int shardingCount = availableTargetNames.size(); int hashNum = ShardingUtils.hash(value, shardingCount); Iterator it = availableTargetNames.iterator(); String targetName; do { if (!it.hasNext()) { throw new UnsupportedOperationException(); } targetName = (String) it.next(); } while (!targetName.endsWith(hashNum + "")); log.debug("simpleHashShardingAlgorithm--shardingCount:{},columnName:{},tableName:{},columnValue:{},recent return target is : {}", new Object[]{shardingCount, columnName, tableName, value, targetName}); return targetName; } ``` (2)preparedstatement mode can greatly enhance performance, but there is a big bug when using multithreading has thread problems.Because of using English, I can't describe this problem very well,I fixed this bug by using ThreadLocal in `MySQLBinaryStatement`. I'm sure you'll see what I mean. This is my code: ```java @RequiredArgsConstructor @Getter @Setter public final class MySQLBinaryStatement { private final String sql; private final int parametersCount; //private List<MySQLBinaryStatementParameterType> parameterTypes; ThreadLocal<List<MySQLBinaryStatementParameterType>> mapCurrentParameterTypes = new ThreadLocal<>(); public List<MySQLBinaryStatementParameterType> getParameterTypes() { return mapCurrentParameterTypes.get(); } public void setParameterTypes(List<MySQLBinaryStatementParameterType> parameterTypes) { mapCurrentParameterTypes.set(parameterTypes); } } ``` (3)And,when using preparedstatement in jdbc,if the sql is large enough,parameter will be cutted lead to 'java.sql.SQLException: Parameter index out of bounds. 22465 is not between valid values of 1 and 22464'.I debugger it,find preparedstatement returns different with single Mysql,parameterCount is wrong. You sincerely YoungLu
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
