Affects: 5.2.5
If inside an already present transaction I execute a method annotated with @CacheEvict and @Transactional(propagation = REQUIRES_NEW), the cache is evicted only after the top level transaction is commited.
Not sure if this is a bug or expected behaviour.
Comment From: snicoll
It shouldn't do that. The evict should be applied when the transaction in which the operation was performed commit. The only thing that I can think of is a method that is both annotated with @Transactional(propagation = REQUIRES_NEW) and @CacheEvict with something messed up in the way proxies are applied.
Can you share a small sample that reproduces the problem you've described? A zip or a link to a github repo. Thank you.
Comment From: ankurtrapasiya
@snicoll - May I please look into this issue?
Comment From: snicoll
@ankurtrapasiya thanks for offering to help but I'd like to check the sample I've requested from @egotsev first.
Comment From: egotsev
https://github.com/egotsev/spring-transaction-aware-cache-example
After creating the isolated example as you suggested, I realised that I foolishly blamed spring cache for the problem I had. The cache is actually evicted but I get the same result because the default isolation level of MariaDB is repeatable read.
Sorry for bothering you. :)
Comment From: snicoll
Thanks for letting us know @egotsev