clearing the cache when rejoining the cluster
by Mats Henrikson
Hi,
I am using JBossCache 3.2 as a Hibernate 2nd level cache in JBoss
(although my problem applies to standalone caches as well). I have a
number of JVMs configured in a cluster, currently configured as
INVALIDATION_SYNC.
Occasionally, one of the JVMs will for whatever reason fall out and
get shunned by the cache cluster (long GC, network blip, etc), at
which point we run into trouble. Since are running synchronously all
the other JVMs will now start throwing ReplicationExceptions until the
missing JVM is shunned, since they don't get a response from the
missing JVM. I may be able to deal with this by changing the cluster
to INVALIDATION_ASYNC.
However, when the shunned host rejoins the cluster, whether the
cluster is SYNC or ASYNC, it is now possible that it has missed a
number of invalidation messages, and as a result may have stale data.
This is the problem I am trying to address.
Ideally, JBossCache would have a configuration option I could set to
tell it to clear the cache whenever it rejoins a cluster. I've not
been able to find any option like that. My other solution, if the
cache was running standalone, would be to register for JMX
notifications of org.jboss.cache.ViewChanged events, and then I could
clear the cache myself when a suitable ViewChanged event occurs.
Unfortunately because the cache is inside Hibernate, it doesn't appear
that I am able to register for those events since it seems that
Hibernate doesn't expose a CacheJmxWrapper MBean.
Is there an alternative solution to this problem?
Regards,
Mats Henrikson
13 years, 6 months