Unexpected Locking on read
fatbatman Mar 10, 2009 8:59 AMHi.
Firstly I've been using JBossCache for a while now and it's a fantastic piece of technology.
That said, I've recently upgraded to JBossAS 5.0.1 and hence to cache 3, and I'm getting some unexpected locking problems.
I've tried to isolate the problem without much luck but have managed to replicate something similar that seems strange.
I deploy the cache in the old JMX style - pojocache-service.xml
<?xml version="1.0" encoding="UTF-8" ?> <server> <mbean code="org.jboss.cache.pojo.jmx.PojoCacheJmxWrapper" name="jboss.cache:service=PojoCache"> <depends>jboss:service=TransactionManager</depends> <depends>jboss.j2ee:jar=jade.jar,name=UserManagerBean,service=EJB3</depends> <depends>jboss.j2ee:jar=jade.jar,name=GameManagerBean,service=EJB3</depends--> <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.JBossTransactionManagerLookup</attribute> <attribute name="IsolationLevel">REPEATABLE_READ</attribute> <attribute name="CacheMode">REPL_SYNC</attribute> <attribute name="ClusterName">PojoCacheCluster</attribute> <attribute name="ClusterConfig"> <config> <UDP mcast_addr="228.1.2.3" mcast_port="48866" 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="false"/> <PING timeout="2000" num_initial_members="3"/> <MERGE2 min_interval="10000" max_interval="20000"/> <FD shun="true"/> <FD_SOCK/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192"/> <UNICAST timeout="600,1200,2400,4800"/> <pbcast.STABLE desired_avg_gossip="400000"/> <FC max_credits="2000000" min_threshold="0.10"/> <FRAG2 frag_size="8192"/> <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/> <pbcast.STATE_TRANSFER/> </config> </attribute> <attribute name="FetchInMemoryState">true</attribute> <attribute name="InitialStateRetrievalTimeout">15000</attribute> <attribute name="SyncReplTimeout">15000</attribute> <!-- Set very low to help recreating the problem --> <attribute name="LockAcquisitionTimeout">100</attribute> </mbean> </server>
I access the cache via JMX as follows;
public static org.jboss.cache.pojo.PojoCache getPojoCache() throws Exception { MBeanServer mbs = MBeanServerLocator.locateJBoss(); PojoCacheJmxWrapperMBean cache = (PojoCacheJmxWrapperMBean) MBeanServerInvocationHandler.newProxyInstance(mbs, new ObjectName("jboss.cache:service=PojoCache"), PojoCacheJmxWrapperMBean.class, false); return cache.getPojoCache(); }
Add a Map to it for testing;
getPojoCache().attach("XXX", new Hashtable<String,String>());
I then run two threads one that writes data to the map, the other read from the map.
There are no other threads accessing this note of the cache.
Note - I don't define my own transactions.
Every so often I get a TimeoutException: Unable to acquire lock on Fqn ...
even though only one thread is ever writing to this node.
I thought there wasn't any locking when a element is reading from the cache? What am I doing wrong here? could it be related to me going through JMX?
Note - When I try the same thing in a stand alone test using PojoCacheFactory.createCache(configFile, toStart); all is fine.
regards
James