You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Lin <me...@linlyu.com> on 2015/12/29 03:42:51 UTC

CacheEvent.hasOldValue() is not right with Transactional Atomicity Mode.

Hi, all,


For a new cache without any data,  I think CacheEvent with a put operation, should not be hasOldValue() == true.


This is my test case to regenerate it.
public void testCacheEvent() throws Exception {
    Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
    final AtomicLong oldValCnt = new AtomicLong(0);
    ignite.events().localListen(new IgnitePredicate<CacheEvent>() {
                                    @Override
                                    public boolean apply(CacheEvent event) {
                                        if (event.hasOldValue())
                                            oldValCnt.incrementAndGet();
                                        return true;
                                    }
                                }, EventType.EVT_CACHE_OBJECT_PUT);

    CacheConfiguration cacheCfg = new CacheConfiguration("hasOldValueCache");
    cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

    IgniteCache cache = ignite.createCache(cacheCfg);
    cache.put(1,"val1");
    assertEquals(0, oldValCnt.get());
}


In Atomic mode, the assertion is right, but failed in Transactional mode.


It looks that the org.apache.ignite.internal.processors.cache.GridCacheMapEntry#hasValueUnlocked does not work properly  in org.apache.ignite.internal.processors.cache.GridCacheMapEntry#innerSet.




Am I right? and How to fix it ?


Thanks for your help.




Lin.

Re: CacheEvent.hasOldValue() is not right with TransactionalAtomicity Mode.

Posted by Lin <me...@linlyu.com>.
Hi Denis,


Thanks for your information. I will watch it, thanks again.


Regards,
Lin




------------------ Original ------------------
From:  "Denis Magda";<dm...@gridgain.com>;
Date:  Tue, Dec 29, 2015 04:28 PM
To:  "user"<us...@ignite.apache.org>; 

Subject:  Re: CacheEvent.hasOldValue() is not right with TransactionalAtomicity Mode.



                   Hi Lin,
     
     This is a known bug that the community has run into recently
     https://issues.apache.org/jira/browse/IGNITE-2231
     
     You can start watching the issue in order to be notified on any     progress change.
     
     Regards,
     Denis

Re: CacheEvent.hasOldValue() is not right with Transactional Atomicity Mode.

Posted by Denis Magda <dm...@gridgain.com>.
Hi Lin,

This is a known bug that the community has run into recently
https://issues.apache.org/jira/browse/IGNITE-2231

You can start watching the issue in order to be notified on any progress 
change.

Regards,
Denis

On 12/29/2015 5:42 AM, Lin wrote:
> Hi, all,
>
> For a new cache without any data,  I think CacheEvent with a put 
> operation, should not be hasOldValue() == true.
>
> This is my test case to regenerate it.
> public void testCacheEvent() throws Exception {
>      Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
>      final AtomicLong oldValCnt =new AtomicLong(0);
>      ignite.events().localListen(new IgnitePredicate<CacheEvent>() {
>                                      @Override public boolean apply(CacheEvent event) {
>                                          if (event.hasOldValue())
>                                              oldValCnt.incrementAndGet();
>                                          return true;
>                                      }
>                                  }, EventType.EVT_CACHE_OBJECT_PUT);
>
>      CacheConfiguration cacheCfg =new CacheConfiguration("hasOldValueCache");
>      cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>
>      IgniteCache cache = ignite.createCache(cacheCfg);
>      cache.put(1,"val1");
>      assertEquals(0, oldValCnt.get());
> }
>
> In Atomic mode, the assertion is right, but failed in Transactional mode.
>
> It looks that 
> the org.apache.ignite.internal.processors.cache.GridCacheMapEntry#hasValueUnlocked 
> does not work properly 
>  in org.apache.ignite.internal.processors.cache.GridCacheMapEntry#innerSet.
>
>
> Am I right? and How to fix it ?
>
> Thanks for your help.
>
>
> Lin.
>