[infinispan-dev] Issue with transaction rollback

Zdeněk Henek vrablik at gmail.com
Sun Nov 10 02:22:16 EST 2013


Hi Faseela,

there is blog entry about this subject:
blog.infinispan.org/2013/07/store-data-by-reference-or-by-value.html

but really it is better not to use mutable objects in cache / all
application objects which may be accessed by multiple
threads. You save yourself a lot of clone calls.

Regards,
Zdenek Henek


On Sun, Nov 10, 2013 at 7:58 AM, Faseela K <faseela.k at ericsson.com> wrote:

> Hi Sanne,
>
> Thanks for the reply.
> Is there any infinispan "get" api, which returns a copy of the actual
> object, rather than returning the reference?
> Because, in my case, I need the value stored in the cache to arrive at the
> new value.
> Just wanted to know if it is possible to solve the issue without cloning
> the object.
>
> Thanks,
> Faseela
>
>
> -----Original Message-----
> From: infinispan-dev-bounces at lists.jboss.org [mailto:
> infinispan-dev-bounces at lists.jboss.org] On Behalf Of Sanne Grinovero
> Sent: Sunday, November 10, 2013 2:21 AM
> To: infinispan -Dev List
> Subject: Re: [infinispan-dev] Issue with transaction rollback
>
> Hi Faseela,
> you should not attempt to mutate the value retrieved from the Cache.
> I would suggest to only store immutable objects in a Cache; in other words
> rather than invoking a setter on property Name, replace the entry with a
> new instance of Rollback which has the new name.
>
> Sanne
>
> On 9 November 2013 19:31, Faseela K <faseela.k at ericsson.com> wrote:
> > Hi,
> >
> >    The issue I mentioned below was not related to nested transactions.
> >    I debugged further, and the issue narrowed down to the following:
> >
> >       EmbeddedCacheManager manager = new
> > DefaultCacheManager("config/infinispan-config.xml");
> >       Configuration rc = manager.getCacheConfiguration("transaction");
> >       manager.defineConfiguration("test1", rc);
> >       ConcurrentMap<String, Rollback> cache1 = manager.getCache("test1");
> >       TransactionManager tm =
> >
> manager.getCache("transaction").getAdvancedCache().getTransactionManager();
> >       Rollback t1 = new Rollback("k1", "v1");
> >       cache1.put("k1", t1);
> >       tm.begin();
> >       Rollback tmp = cache1.get("k1");
> >       tmp.setName("abcd");
> >       cache1.replace("k1", tmp);
> >       tm.rollback();
> >
> >       Even after doing the rollback, "k1" still points to name "abcd".
> >       Only if I do a cache1.get("k1").clone(), rollback is functioning
> > as expected.
> >
> > Thanks,
> > Faseela
> >
> >
> >
> > ________________________________
> > From: infinispan-dev-bounces at lists.jboss.org
> > [mailto:infinispan-dev-bounces at lists.jboss.org] On Behalf Of Faseela K
> > Sent: Friday, November 08, 2013 6:39 PM
> > To: infinispan -Dev List
> > Subject: [infinispan-dev] Issue with nested transactions
> >
> > Hi,
> >
> >   I have two osgi bundles, both having two separate caches.
> >   I explicitly started a transaction in Bundle 1.
> >   Within the transaction, I am accessing Bundle 2's cache(this is
> > implicit transaction, since autocommit is true), and modifying it.
> >   Now, there is some operation on Bundle 1's cache done.
> >   After this operation, if I do a roll back,  Only Bundle 1's cache
> > operations are getting rolled back.
> >   I am not getting any error, though.
> >   Does anyone know why this happens?
> >
> >   Steps :
> >
> >     1) Bundle 1 - transaction started
> >     2) update bundle 2 cache
> >     3) update bundle 1 cache
> >     4) Bundle 1 - transaction rollback
> >
> >     Issue : bundle 2 cache not rolled back!!
> >
> > Thanks,
> > Faseela
> >
> >
> > _______________________________________________
> > infinispan-dev mailing list
> > infinispan-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/infinispan-dev
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/infinispan-dev/attachments/20131110/8296a1ba/attachment-0001.html 


More information about the infinispan-dev mailing list