ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Goncharuk <alexey.goncha...@gmail.com>
Subject Re: putting entity into cache while commiting.Why!?
Date Thu, 30 Mar 2017 09:43:13 GMT
Aleksey,

It looks like in your test the result of method atomicityMode() is not used
because you do getOrCreateCache() without the configuration argument, which
will create a cache with a default configuration, which is ATOMIC.

2017-03-30 12:06 GMT+03:00 ALEKSEY KUZNETSOV <alkuznetsov.sb@gmail.com>:

> public class FooTest extends GridCacheAbstractSelfTest {
>
>     @Override
>     protected void afterTestsStopped() throws Exception {
>         super.afterTestsStopped();
>         stopAllGrids();
>     }
>
>     @Override
>     protected int gridCount() {
>         return 3;
>     }
>
>     @Override
>     protected CacheMode cacheMode() {
>         return CacheMode.PARTITIONED;
>     }
>
>     @Override
>     protected CacheAtomicityMode atomicityMode() {
>         return CacheAtomicityMode.TRANSACTIONAL;
>     }
>
>     public void testLoggingTransactions() throws InterruptedException {
>         Ignite ignite0 = ignite(0);
>         IgniteTransactions transactions = ignite0.transactions();
>         IgniteCache<String, String> cache =
> ignite0.getOrCreateCache("testCache");
>         Object monitor = new Object();
>
>         GridTestUtils.runAsync(new Callable<Object>() {
>             @Override
>             public Object call() throws Exception {
>                 synchronized (monitor){
>                     doInTransaction(ignite(1), new Callable<Object>() {
>                         @Override
>                         public Object call() throws Exception {
>                             cache.put("key1", "val1");
>                             monitor.wait();
>                             System.out.println("continue first
> transaction");
>                             return null;
>                         }
>                     });
>                 }
>                 return null;
>             }
>         });
>
>         Transaction tx =
> transactions.txStart(TransactionConcurrency.OPTIMISTIC,
> TransactionIsolation.READ_COMMITTED);
>         cache.put("key1", "val1");
>         cache.put("key2", "val2");
>         cache.put("key3", "val3");
>         tx.commit();
>
>     }
> }
>
>
> чт, 30 мар. 2017 г. в 11:55, Alexey Goncharuk <alexey.goncharuk@gmail.com
> >:
>
> > Can you please paste the full example?
> >
> > 2017-03-30 11:50 GMT+03:00 ALEKSEY KUZNETSOV <alkuznetsov.sb@gmail.com>:
> >
> > > But i managed to read dirty. That is my example :
> > >
> > > Ignite ignite0 = ignite(0);
> > > IgniteTransactions transactions = ignite0.transactions();
> > > IgniteCache<String, String> cache =
> > ignite0.getOrCreateCache("testCache");
> > > Object monitor = new Object();
> > >
> > > GridTestUtils.runAsync(new Callable<Object>() {
> > >     @Override
> > >     public Object call() throws Exception {
> > >         synchronized (monitor){
> > >             doInTransaction(ignite(1), new Callable<Object>() {
> > >                 @Override
> > >                 public Object call() throws Exception {
> > >                     cache.put("key1", "val1");
> > >                     monitor.wait();
> > >                     return null;
> > >                 }
> > >             });
> > >         }
> > >         return null;
> > >     }
> > > });
> > >
> > > Transaction tx =
> > > transactions.txStart(TransactionConcurrency.OPTIMISTIC,
> > > TransactionIsolation.READ_COMMITTED);
> > > cache.put("key1", "val1");
> > >
> > > And through debugging cache.put() method i can see in method
> > > *org.apache.ignite.internal.processors.cache.distributed.
> > > near.GridNearTxLocal#enlistWriteEntry*
> > > that "key1" already *EXISTS *in internal cache :
> > cacheCtx.cache().entryEx()
> > > returns not null.
> > >
> > > ср, 29 мар. 2017 г. в 20:11, Alexander Fedotov <
> > > alexander.fedotoff@gmail.com
> > > >:
> > >
> > > Hello Aleksey,
> > >
> > > No, the enlisted entry won't be visible for other transactions. Dirty
> > reads
> > > are not allowed in Ignite.
> > >
> > > Kind regards,
> > > Alex
> > >
> > > 29 марта 2017 г. 7:36 PM пользователь "ALEKSEY KUZNETSOV"
<
> > > alkuznetsov.sb@gmail.com> написал:
> > >
> > > Hello, Igniters! I have one more question to you. Will appreciate any
> > help.
> > > Consider cache with near , dht configured not null.
> > > When we start commit transaction , in method
> > > *org.apache.ignite.internal.processors.cache.distributed.
> > > near.GridNearTxLocal#enlistWriteEntry*
> > > we put newly created entry into cache by executing entryEx().
> > > I wonder if this entry will became visible for other transactions!?
> > > --
> > >
> > > *Best Regards,*
> > >
> > > *Kuznetsov Aleksey*
> > >
> > > --
> > >
> > > *Best Regards,*
> > >
> > > *Kuznetsov Aleksey*
> > >
> >
> --
>
> *Best Regards,*
>
> *Kuznetsov Aleksey*
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message