-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: Hibernate cluster - cant disable caching, cant use TreeCache
PostPosted: Tue Nov 08, 2005 1:39 pm 
Newbie

Joined: Fri Nov 04, 2005 12:30 pm
Posts: 6
Hello friends,

I've trying to solve a cluster-cache probem for the past 2 weeks, reading all available posts on this forum - but all solutions I could find does not seem to work. At this stage I'm desperate, hopefully someone can point out where things go wrong...

Below is my setup (all on one machine):

1. Apache 1.3.33 - acts as a load-balancer between 2 Tomcat 5.0 servers
2. Tomcat1 v5.0
3. Tomcat2 v5.0
4. MySQL 4.1.10
5. OS: Windows XP

Tomcat1 and Tomcat2 host Spring-enabled web application that uses Hibernate3 for persistance. Having a cluster of 2 tomcat servers a cache problem occured - either use distributed cache (TreeCache) or disable cache altogether (easier but less elegant approach). In short - i tried both, and none worked.

1. Disable all caching

I have added the following parameters to hibernate.cfg.xml on both Tomcats:
<name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property >
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">false</property>

However, updates done on one instance were not visible on the other tomcat, and vise versa. Why? Is there a config parameter I missed?

2. I configured JBoss TreeCache - the distributed cache started up fine, I could see communication handshake between two tomcats, however again the updates on one server not visible to the other, and no errors in the logs.

Below is treecache.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!-- ===================================================================== -->
<!-- -->
<!-- Sample TreeCache Service Configuration -->
<!-- -->
<!-- ===================================================================== -->

<server>

<classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>


<!-- ==================================================================== -->
<!-- Defines TreeCache configuration -->
<!-- ==================================================================== -->

<mbean code="org.jboss.cache.TreeCache"
name="jboss.cache:service=TreeCache">

<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
<depends>jboss:service=ClientUserTransaction</depends>

<!--
Configure the TransactionManager
-->
<!-- attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute -->

<!--
Node isolation level : SERIALIZABLE
REPEATABLE_READ (default)
READ_COMMITTED
READ_UNCOMMITTED
NONE
-->
<attribute name="IsolationLevel">READ_COMMITTED</attribute>

<!--
Valid modes are LOCAL
REPL_ASYNC
REPL_SYNC
-->
<attribute name="CacheMode">REPL_SYNC</attribute>

<!-- Name of cluster. Needs to be the same for all clusters, in order
to find each other
-->
<attribute name="ClusterName">TreeCache-Cluster</attribute>

<!-- JGroups protocol stack properties. Can also be a URL,
e.g. file:/home/bela/default.xml
<attribute name="ClusterProperties"></attribute>
-->

<attribute name="ClusterConfig">
<config>
<!-- UDP: if you have a multihomed machine,
set the bind_addr attribute to the appropriate NIC IP address -->
<!-- UDP: On Windows machines, because of the media sense feature
being broken with multicast (even after disabling media sense)
set the loopback attribute to true -->
<UDP mcast_addr="228.1.3.160" mcast_port="45567" bind_addr="127.0.0.1"
ip_ttl="64" ip_mcast="true"
mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
loopback="true"/>
<PING timeout="2000" num_initial_members="3"
up_thread="false" down_thread="false"/>
<MERGE2 min_interval="10000" max_interval="20000"/>
<FD shun="true" up_thread="true" down_thread="true"/>
<VERIFY_SUSPECT timeout="1500"
up_thread="false" down_thread="false"/>
<pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
up_thread="false" down_thread="false"/>
<pbcast.STABLE desired_avg_gossip="20000"
up_thread="false" down_thread="false"/>
<UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
down_thread="false"/>
<FRAG frag_size="8192"
down_thread="false" up_thread="false"/>
<pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
shun="true" print_local_addr="true"/>
<pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/>
</config>
</attribute>

<!--
Max number of entries in the cache. If this is exceeded, the
eviction policy will kick some entries out in order to make
more room
-->
<attribute name="MaxCapacity">20000</attribute>

<!--
The max amount of time (in milliseconds) we wait until the
initial state (ie. the contents of the cache) are retrieved from
existing members in a clustered environment
-->
<attribute name="InitialStateRetrievalTimeout">20000</attribute>

<!--
Number of milliseconds to wait until all responses for a
synchronous call have been received.
-->
<attribute name="SyncReplTimeout">10000</attribute>

<!-- Max number of milliseconds to wait for a lock acquisition (15000 by default) -->
<attribute name="LockAcquisitionTimeout">400000</attribute>

<!-- Max number of milliseconds we hold a lock (not currently
implemented) -->
<attribute name="LockLeaseTimeout">600000</attribute>

<!-- Name of the eviction policy class. Not supported now. -->
<attribute name="EvictionPolicyClass"></attribute>

<attribute name="FetchStateOnStartup">true</attribute>
<!-- attribute name="CacheLoaderClass">org.jboss.cache.loader.RpcDelegatingCacheLoader</attribute -->
<attribute name="CacheLoaderShared">true</attribute>
<!-- attribute name="CacheLoaderFetchTransientState">true</attribute -->
<!-- attribute name="CacheLoaderFetchPersistentState">false</attribute -->

</mbean>

</server>

I tried to comment out/comment in different parameters - still no luck.

Please, help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 3:29 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Quote:
However, updates done on one instance were not visible on the other tomcat, and vise versa


Waht is your exact expectation?

If you have no second level cache (there's nothing you have to configure for this, that's the default!), every commited DML call to the DB is visible for all client transaction (the exact behaviour depends on the transaction isolation level).

If you have second level caching in a cluster your cached data on one machine might get stale because it has been changed by an other one. The easiest way to cope with this problem is to set timouts for your cache in order to get rid of the stale data after a wile. If this isn't enough you have to use the JBossChache which can synchronize the distributed caches.

HTH
Ernst


Top
 Profile  
 
 Post subject: Re: Hibernate cluster - cant disable caching, cant use TreeC
PostPosted: Wed Nov 09, 2005 3:48 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It looks like you do not commit transaction or do not update any records in database.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 6:22 am 
Newbie

Joined: Fri Nov 04, 2005 12:30 pm
Posts: 6
My expectation is that any udpate on any instance will be instantly visible to another instance. In my case however updates are visible ONLY on instance that DML took place. If I add a record on Tomcat1 - only hits to Tomcat1 instance will see this new record, etc. no matter how much time passed.

That's why i tried to disable all caching so that any request would result in DB quering, however cache disabling does not seem to work (unless i missed some parameter - please see my config xml in original post).

Then I tried to use TreeCache (That uses JBossCache - right? ) - it started OK, however no session sync takes place... Again treecache.xml is given in original post - please help if i missed something.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:05 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Put
Code:
<property name="show_sql">false</property>

into you hibernate.cfg.xml.

Are there any updae/insert/deletes sent to the DB? If not, baliukas is right.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:06 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Sorry, I was to fast with typing :-). It should of course look like this

Code:
<property name="show_sql">true</property>


HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:32 am 
Newbie

Joined: Fri Nov 04, 2005 12:30 pm
Posts: 6
Hi Ernst,

Thanks for coming back on my issue...

Updates are definately taken place - if i restart both tomcats, then all udpates are visible to both instances. Will this imply that session is commited as well?
I am using Spring Hibernate support.

Will add this tag and see if it can shed more light...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:33 am 
Newbie

Joined: Fri Nov 04, 2005 12:30 pm
Posts: 6
Just checked my config file - show_sql property was already set to true... Should i look for commit() calls?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 10:49 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
I'm using http://www.p6spy.com/ to resolve JDBC problems. It acts as Proxy JDBC driver and logs everything which goes accross the JDBC interface.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 11:13 am 
Newbie

Joined: Fri Nov 04, 2005 12:30 pm
Posts: 6
Thanks Ernst, will try...

Since i still do not see the problem - could anyone who managed to successfully configure and use Hibernate and TreeCache please post the treecache.xml and hibernate.cfg.xml?

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 7:48 am 
Newbie

Joined: Fri Nov 04, 2005 12:30 pm
Posts: 6
Hi,

I've progressed somewhat in my investigations - i could see "select ..." statements on each of tomcat instances for every request, however updates were visible only on instance where they took place.

this lead me to believe that session do not flush to database.

Can you please suggest how to force session to flush to db after each request? I am using Spring Hibernate support classes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.