CacheStore and Transaction

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

CacheStore and Transaction

Alisher Alimov
Hello!

I found bug when using CacheStore with Transaction or it’s expected behaviour?

Example: 

CacheConfiguration cacheConfiguration = new CacheConfiguration("test.no-op");
cacheConfiguration.setWriteThrough(true);
cacheConfiguration.setCacheWriterFactory(noOpCacheWriterFactory);
cacheConfiguration.setWriteBehindBatchSize(1);

try (Transaction transaction = ignite.transactions().txStart()) {
cache.put(1, 1); // will be flushed here
cache.put(2, 2);

transaction.rollback();
}

Does not matter if transaction was not completed or rollback, dirty records are flushed through CacheWriter and persistent storage will contains inconsistent data.

Expected behaviour: only committed data must be flushed


With best regards
Alisher Alimov





signature.asc (465 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: CacheStore and Transaction

V.Pyatkov
Hi

Make sure are you using transactional cache.

On Mar 19, 2017 10:32 PM, "Alisher Alimov" <[hidden email]> wrote:

> Hello!
>
> I found bug when using CacheStore with Transaction or it’s expected
> behaviour?
>
> Example:
>
> CacheConfiguration cacheConfiguration = new CacheConfiguration("test.no-op");
> cacheConfiguration.setWriteThrough(true);
> cacheConfiguration.setCacheWriterFactory(noOpCacheWriterFactory);
> cacheConfiguration.setWriteBehindBatchSize(1);
>
>
> try (Transaction transaction = ignite.transactions().txStart()) {
>     cache.put(1, 1); // will be flushed here
>     cache.put(2, 2);
>
>     transaction.rollback();
> }
>
>
> Does not matter if transaction was not completed or rollback, dirty
> records are flushed through CacheWriter and persistent storage will
> contains inconsistent data.
>
> Expected behaviour: only committed data must be flushed
>
>
> With best regards
> Alisher Alimov
> [hidden email]
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: CacheStore and Transaction

V.Pyatkov
I mean *CacheConfiguration.setAtomicityMode*[1]
Because transactions makes a sense only for TRANSACTIONAL cache.

[1]: https://apacheignite.readme.io/docs/transactions#section-atomicity-mode

On Sun, Mar 19, 2017 at 11:14 PM, Vladislav Pyatkov <[hidden email]>
wrote:

> Hi
>
> Make sure are you using transactional cache.
>
> On Mar 19, 2017 10:32 PM, "Alisher Alimov" <[hidden email]>
> wrote:
>
>> Hello!
>>
>> I found bug when using CacheStore with Transaction or it’s expected
>> behaviour?
>>
>> Example:
>>
>> CacheConfiguration cacheConfiguration = new CacheConfiguration("test.no-op");
>> cacheConfiguration.setWriteThrough(true);
>> cacheConfiguration.setCacheWriterFactory(noOpCacheWriterFactory);
>> cacheConfiguration.setWriteBehindBatchSize(1);
>>
>>
>> try (Transaction transaction = ignite.transactions().txStart()) {
>>     cache.put(1, 1); // will be flushed here
>>     cache.put(2, 2);
>>
>>     transaction.rollback();
>> }
>>
>>
>> Does not matter if transaction was not completed or rollback, dirty
>> records are flushed through CacheWriter and persistent storage will
>> contains inconsistent data.
>>
>> Expected behaviour: only committed data must be flushed
>>
>>
>> With best regards
>> Alisher Alimov
>> [hidden email]
>>
>>
>>
>>
>>


--
Vladislav Pyatkov
Reply | Threaded
Open this post in threaded view
|

Re: CacheStore and Transaction

Valentin Kulichenko
Even with transactional cache, it's correct that updates are propagated to
CacheWriter methods. It's up to CacheStore implementation to maintain
underlying transaction on persistence store and commit or rollback it
depending on cache transaction status. Usually it's done with the help of
session listeners [1].

[1]
https://ignite.apache.org/releases/1.9.0/javadoc/org/apache/ignite/cache/store/CacheStoreSessionListener.html

-Val

On Mon, Mar 20, 2017 at 8:12 AM, Vladislav Pyatkov <[hidden email]>
wrote:

> I mean *CacheConfiguration.setAtomicityMode*[1]
> Because transactions makes a sense only for TRANSACTIONAL cache.
>
> [1]: https://apacheignite.readme.io/docs/transactions#section-
> atomicity-mode
>
> On Sun, Mar 19, 2017 at 11:14 PM, Vladislav Pyatkov <[hidden email]>
> wrote:
>
> > Hi
> >
> > Make sure are you using transactional cache.
> >
> > On Mar 19, 2017 10:32 PM, "Alisher Alimov" <[hidden email]>
> > wrote:
> >
> >> Hello!
> >>
> >> I found bug when using CacheStore with Transaction or it’s expected
> >> behaviour?
> >>
> >> Example:
> >>
> >> CacheConfiguration cacheConfiguration = new CacheConfiguration("test.no-
> op");
> >> cacheConfiguration.setWriteThrough(true);
> >> cacheConfiguration.setCacheWriterFactory(noOpCacheWriterFactory);
> >> cacheConfiguration.setWriteBehindBatchSize(1);
> >>
> >>
> >> try (Transaction transaction = ignite.transactions().txStart()) {
> >>     cache.put(1, 1); // will be flushed here
> >>     cache.put(2, 2);
> >>
> >>     transaction.rollback();
> >> }
> >>
> >>
> >> Does not matter if transaction was not completed or rollback, dirty
> >> records are flushed through CacheWriter and persistent storage will
> >> contains inconsistent data.
> >>
> >> Expected behaviour: only committed data must be flushed
> >>
> >>
> >> With best regards
> >> Alisher Alimov
> >> [hidden email]
> >>
> >>
> >>
> >>
> >>
>
>
> --
> Vladislav Pyatkov
>