Question

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:

  1. 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.
  2. 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?

Was it helpful?

Solution

It appeared that the <defaultCache> was not declared as clustered using <terracotta />. All others were, so I didn't at first notice this oversight.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top