BaseExecutor.query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, CacheKey key, BoundSql boundSql)

MyBatis Whether the local cache needs to be locked to ensure data correctness? MyBatis Whether the local cache needs to be locked to ensure data correctness?

When A thread A perform enclosing localCache. PutObject (key, ExecutionPlaceholder. EXECUTION_PLACEHOLDER), Is thread B executing to list = resultHandler == null? (List)this.localCache.getObject(key) : null; castException, a data inconsistency problem, occurs. Do you need to lock when updating localCache?

Comment From: harawata

Hello @lyf712 ,

Not unless you share something that is not thread safe (e.g. SqlSession). Please read the documentation. https://mybatis.org/mybatis-3/getting-started.html

If you still think there is a bug, please provide a repro so that we can investigate.

Comment From: lyf712

get it! thank u