sharding-jdbc can't work in multi thread concurrent
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
4.0.0.M1
Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-JDBC
Expected behavior
Actual behavior
multi thread concurrent can't work
Reason analyze (If you can)
InsertStatement(other Statement no validation) is not thread safe, PreparedStatementRoutingEngine#route fetch Statement used cache

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Example codes for reproduce this issue (such as a github link).
Which version is stable and usable now?
new question
ShardingRule i think is singleton
org.apache.commons.collections4.map.ReferenceMap is not thread-safe, cache used with it no problem in multi thread concurrent?

Could change field 'parsingResultCache' to #ThreadLocal in #ShardingRule?
@mfeng-ya it caused by shared SQLStatement, ParsingResultCache is global cache, it cloud not change to ThreadLocal
@codefairy08 ParsingResultCache may be could refer to the ConcurrentReferenceHashMap in hibernate-validator's util package

@mfeng-ya It does not work, It is not caused by ParsingResultCache , the instance in ParsingResultCache should not be changed.
@codefairy08 I see, however it's a new question
I have met a problem while using sharing-jdbc version 3.1.0. Thread hang in with high CPU load. Thread call stack show thread hang in HashMap.getEntry(). So how can i fix this problem beacuse of HashMap is not thread save in ParsingResultCache.
This should be a VERY BASIC issue which should not happen since everybody know that HashMap is NOT THREAD-SAFE.
mark ParsingResultCache