-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Concurrent access to ParsedSql cache in NamedParameterJdbcTemplate #24197
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
Concurrent access to ParsedSql cache in NamedParameterJdbcTemplate #24197
Conversation
Is it necessary to cache twice
|
…sting ParsedSql instances anymore
@rengy-github |
@benelog |
@rengy-github |
I think don't use sync or just put |
My puzzle is whether there is problem with the other thread get when one thread puts Could you send me a link about this, thank you |
@rengy-github
For the above reason, public V get(Object key) {
synchronized (mutex) {return m.get(key);}
} Calling https://d2.naver.com/helloworld/1326256 The following artice is about similar issues in HashMap. https://mailinator.blogspot.com/2009/06/beautiful-race-condition.html |
@benelog |
I've addressed this using a revised version our own |
now #22789 got fixed too 👍 |
NamedParameterJdbcTemplate.getParsedSql(Sting)
can be a bottleneck under high load as it holds a global lock bythis.parsedSqlCache
.This PR tried to improve the performance by the combination of a ConcurrentHashMap and a LinkedHashMap.
I referenced 06c6cbb6b92 and
#7831 (comment)