Mutable objects cached in Infinispan
by Phillip Henry
Greetings, folks,
I've been tasked by my company with investigating Infinispan as a
distributed cache solution. I've played around with the tests that come with
it but I still have some questions. I hope this is an appropriate forum in
which I can ask them.
My question is this: how does Infinispan handle the caching of mutable
objects?
For instance, taking org.infinispan.replication.SyncReplLockingTest as a
template, I wrote some test code in which a reading thread gets a reference
to a particular element in the cache (within a transaction). While the
transaction of this reading thread was still in-flight, an updating thread
was able to mutate the object (also within a transaction). Since reading and
updating threads have a reference to the same object, race conditions are
introduced.
Note: the reading thread never explicitly locked this element in the cache.
I just assumed there would be some implicit locking. It could explicitly
lock the object but wouldn't this degrade performance? Isn't this exactly
why MVCC was used as a solution - to mitigate this overhead?
Furthermore, rolling back the transaction of the updating thread will not
rollback the changes made to a mutable object. So, am I missing something?
Am I approaching the problem the wrong way?
Regards for any input.
Cheers,
Phill
PS I was playing with the infinispan-5.0.0.ALPHA4 release.
12 years, 12 months
[JBoss JIRA] Created: (ISPN-850) RemoteCache.replaceWithVersion javadoc is incorrect
by Galder Zamarreño (JIRA)
RemoteCache.replaceWithVersion javadoc is incorrect
---------------------------------------------------
Key: ISPN-850
URL: https://issues.jboss.org/browse/ISPN-850
Project: Infinispan
Issue Type: Bug
Components: Cache Server
Affects Versions: 5.0.0.ALPHA1, 4.2.0.Final
Reporter: Galder Zamarreño
Assignee: Mircea Markus
Priority: Minor
Fix For: 5.0.0.BETA1, 5.0.0.Final
replaceWithVersion javadoc is incorrect:
/**
* Removes the given value only if its version matches the supplied version. See {@link #removeWithVersion(Object,
* long)} for a sample usage.
*
* @return true if the method has been replaced
* @see #getVersioned(Object)
* @see VersionedValue
*/
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[JBoss JIRA] Created: (ISPN-957) Make local suite to run with JBossTM
by Mircea Markus (JIRA)
Make local suite to run with JBossTM
------------------------------------
Key: ISPN-957
URL: https://issues.jboss.org/browse/ISPN-957
Project: Infinispan
Issue Type: Feature Request
Components: Test Suite, Transactions
Reporter: Mircea Markus
Assignee: Mircea Markus
Fix For: 5.0.0.Final
Suite runs faster with JBossTM (vs DummyTM).
A explanation for JBossTM over performing DummyTM in spite keeping a tx log on the disk (which dummyTm doesn't) is the fact that it has 2PC optimisations for situations where only one resource is registered. In other words if there is only one cache participating in the transaction (most of our tests are like that) there won't be 2RPC but only one.
It would be good to run the local test suite with JBossTM and CoordinatorEnvironmentBean.commitOnePhase=true and
CoordinatorEnvironmentBean.commitOnePhase=false on the hudson environment. This would be good for performance.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[JBoss JIRA] Created: (ISPN-1034) DefaultCacheManager becomes corrupted after component start Exception
by Raman Gupta (JIRA)
DefaultCacheManager becomes corrupted after component start Exception
---------------------------------------------------------------------
Key: ISPN-1034
URL: https://issues.jboss.org/browse/ISPN-1034
Project: Infinispan
Issue Type: Bug
Components: Cache Server
Affects Versions: 4.2.1.FINAL
Environment: Linux zeus 2.6.35.11-83.fc14.x86_64 #1 SMP Mon Feb 7 07:06:44 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Reporter: Raman Gupta
Assignee: Manik Surtani
Priority: Minor
If Jgroups cluster startup throws an Exception the CacheManager becomes "corrupted", and a retry to get the cache from the CacheManager fails even with the underlying issue removed.
For example, with the following code:
=============================================================
private Cache initCache(String name)
{
Cache cache;
for(int i = 0; i < 2; i++)
{
try
{
System.out.println(i + " cacheManager.getCache");
cache = cacheManager.getCache(name);
System.out.println(i + " cache.start()");
cache.start();
System.out.println(i + " done");
return cache;
}
catch (Exception e)
{
System.out.println(i + " exception:");
e.printStackTrace(System.out);
try
{
Thread.sleep(5000);
}
catch (InterruptedException e1)
{
// ignore
}
}
}
return null;
}
=============================================================
I can get the following output when JGroups does not start (due to an unrelated issue -- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7032558):
0 cacheManager.getCache
0 exception:
org.infinispan.CacheException: Unable to invoke method public abstract void org.infinispan.remoting.transport.Transport.start() on object
at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:174)
at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:889)
at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:687)
at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:589)
at org.infinispan.factories.GlobalComponentRegistry.start(GlobalComponentRegistry.java:137)
at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:137)
at org.infinispan.CacheDelegate.start(CacheDelegate.java:323)
at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:516)
at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:439)
at com.algo.msg.mobjectcache.InfinispanCacheStore.initCache(InfinispanCacheStore.java:105)
at com.algo.msg.mobjectcache.InfinispanCacheStore.init(InfinispanCacheStore.java:88)
at com.algo.msg.mobjectcache.InfinispanCacheStore.main(InfinispanCacheStore.java:396)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:171)
... 16 more
Caused by: org.infinispan.CacheException: org.jgroups.ChannelException: unable to setup the protocol stack
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.buildChannel(JGroupsTransport.java:261)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannel(JGroupsTransport.java:211)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannelAndRPCDispatcher(JGroupsTransport.java:227)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.start(JGroupsTransport.java:154)
... 21 more
Caused by: org.jgroups.ChannelException: unable to setup the protocol stack
at org.jgroups.JChannel.init(JChannel.java:1728)
at org.jgroups.JChannel.<init>(JChannel.java:249)
at org.jgroups.JChannel.<init>(JChannel.java:215)
at org.infinispan.remoting.transport.jgroups.JGroupsTransport.buildChannel(JGroupsTransport.java:258)
... 24 more
Caused by: java.net.SocketException: No such device
at java.net.NetworkInterface.isUp0(Native Method)
at java.net.NetworkInterface.isUp(NetworkInterface.java:327)
at org.jgroups.util.Util.getAddress(Util.java:3406)
at org.jgroups.util.Util.getNonLoopbackAddress(Util.java:3392)
at org.jgroups.stack.Configurator.setDefaultValues(Configurator.java:726)
at org.jgroups.stack.Configurator.setupProtocolStack(Configurator.java:114)
at org.jgroups.stack.Configurator.setupProtocolStack(Configurator.java:53)
at org.jgroups.stack.ProtocolStack.setup(ProtocolStack.java:534)
at org.jgroups.JChannel.init(JChannel.java:1725)
... 27 more
1 cacheManager.getCache
1 cache.start()
1 exception:
org.infinispan.CacheException: Unable to invoke method private void org.infinispan.transaction.xa.TransactionTable.start() on object
at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:174)
at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:889)
at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:687)
at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:589)
at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:147)
at org.infinispan.CacheDelegate.start(CacheDelegate.java:323)
at com.algo.msg.mobjectcache.InfinispanCacheStore.initCache(InfinispanCacheStore.java:108)
at com.algo.msg.mobjectcache.InfinispanCacheStore.init(InfinispanCacheStore.java:88)
at com.algo.msg.mobjectcache.InfinispanCacheStore.main(InfinispanCacheStore.java:396)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:171)
... 13 more
Caused by: java.lang.NullPointerException
at org.infinispan.manager.DefaultCacheManager.addListener(DefaultCacheManager.java:562)
at org.infinispan.transaction.xa.TransactionTable.start(TransactionTable.java:105)
... 18 more
On the second attempt, the Exception is no longer the same, but rather a NPE in the DefaultCacheManager.
The NPE occurs EVEN WHEN the underlying cause of the first Exception(in my case a network interface that was causing JGroups channel init to fail) has been removed during the sleep time between the attempts, and therefore the program is stuck until a new DefaultCacheManager is created. With a dependency injection approach, creating a new manager for retries is not always feasible or desirable.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years