It appeared that the <defaultCache>
was not declared as clustered using <terracotta />
. All others were, so I didn't at first notice this oversight.
Clustered Terracotta Cache Not Updated Across Modules
-
29-11-2021 - |
سؤال
The problem has a lot of components, and I'll try not to miss any:
- EhCache is used with Terracotta for clustering
- EhCache is used both for spring caching and for hibernate 2nd level cache
- in order to have only one cache manager, the cache manager is declared as "shared"
- we have a lot of web modules which are deployed as different webapps
- on internal environments modules are deployed on the same server and are not using Teracotta, on production and staging environments they are deployed on separate servers
- terracotta clustering is using the default "eventual" consistency mode
- ehcache 2.5.2, hibernate 3.6, terracotta 3.0.6
Given these prerequisites, the following happens:
- One web module (web app, deployed on one server) makes a change to hibernate entity. This is supposed to update the cache entry cluster-wide.
- When the object is requested from another web module (another server), even a minute later, a stale object is returned (that is, without the modification made by the first web app) if an entity is loaded by that identifier
The questions are: - Am I right to assume that after making a "save" operation, the 2nd level cache gets the info updated cluster-wide "eventually" (within milliseconds, according to Terracotta docs)? - What could be the possible reasons for that not to happen?
المحلول
لا تنتمي إلى StackOverflow