You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Дмитрий Рябов <so...@gmail.com> on 2017/04/12 16:32:26 UTC
Question about cache and transaction on different nodes
Hello, igniters. I start the node and create a transactional cache on it,
on the other node I start the transaction and "put" in previously created
cache and rollback transaction. So what should I get? Value stored before
transaction or inside rolled transaction?
public void testRollback() throws Exception {
startGrid(0);
startGrid(1);
IgniteCache<Integer, Integer> cache1 = grid( 1).cache(null);
cache1.put(1, 1);
try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC,
READ_COMMITTED)) {
cache1.put(1, 1111);
tx.rollback();
}
assertEquals((Integer) 1, cache1.get(1));
}
The question is why I got 1111 instead of 1? If it is right behaviour - why
it nowhere explained?
Re: Question about cache and transaction on different nodes
Posted by Sergi Vladykin <se...@gmail.com>.
Yes, sorry. The test works correctly: tx started on grid0 does not affect
cache1, because they are on different nodes. Thus the operation
cache1.put(1, 1111) is successfully committed.
Still I would not recommend to rely on any of observed behaviors here,
because Ignite was not designed for mixing caches and transactions from
different nodes in the same code. This behavior is undefined, untested and
may freely change at any time.
Sergi
2017-04-13 0:08 GMT+03:00 Dmitriy Setrakyan <ds...@apache.org>:
> There is no bug.
>
> Dmitriy, you should introduce a variable:
>
> *cache0 = grid(0).cache(null);*
>
> Then you should use cache0 variable to do a cache put.
>
> You cannot use transaction API from grid0 and then cache API from grid1. In
> a normal environment, the cache0 and cache1 variables would not even be
> present in the same JVM - they would be on different physical servers.
>
> D.
>
> On Wed, Apr 12, 2017 at 11:08 AM, Sergi Vladykin <sergi.vladykin@gmail.com
> >
> wrote:
>
> > Looks like a bug to me.
> >
> > Sergi
> >
> > 2017-04-12 21:03 GMT+03:00 Дмитрий Рябов <so...@gmail.com>:
> >
> > > Why not? I do something with cache inside transaction. The only reason
> to
> > > not rollback is another node?
> > >
> > > 2017-04-12 19:52 GMT+03:00 Andrey Mashenkov <
> andrey.mashenkov@gmail.com
> > >:
> > >
> > > > Hi Dmitry,
> > > >
> > > > Looks like you start transaction on node "grid(0)", but update value
> on
> > > > another node "grid(1)".
> > > > So, technically, it is not nested transactions, right?
> > > >
> > > > On Wed, Apr 12, 2017 at 7:32 PM, Дмитрий Рябов <
> somefireone@gmail.com>
> > > > wrote:
> > > >
> > > > > Hello, igniters. I start the node and create a transactional cache
> on
> > > it,
> > > > > on the other node I start the transaction and "put" in previously
> > > created
> > > > > cache and rollback transaction. So what should I get? Value stored
> > > before
> > > > > transaction or inside rolled transaction?
> > > > >
> > > > > public void testRollback() throws Exception {
> > > > > startGrid(0);
> > > > > startGrid(1);
> > > > > IgniteCache<Integer, Integer> cache1 = grid( 1).cache(null);
> > > > > cache1.put(1, 1);
> > > > > try (Transaction tx = grid(0).transactions().
> > txStart(PESSIMISTIC,
> > > > READ_COMMITTED)) {
> > > > > cache1.put(1, 1111);
> > > > > tx.rollback();
> > > > > }
> > > > > assertEquals((Integer) 1, cache1.get(1));
> > > > > }
> > > > >
> > > > >
> > > > > The question is why I got 1111 instead of 1? If it is right
> > behaviour -
> > > > > why it nowhere explained?
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Best regards,
> > > > Andrey V. Mashenkov
> > > >
> > >
> >
>
Re: Question about cache and transaction on different nodes
Posted by Dmitriy Setrakyan <ds...@apache.org>.
There is no bug.
Dmitriy, you should introduce a variable:
*cache0 = grid(0).cache(null);*
Then you should use cache0 variable to do a cache put.
You cannot use transaction API from grid0 and then cache API from grid1. In
a normal environment, the cache0 and cache1 variables would not even be
present in the same JVM - they would be on different physical servers.
D.
On Wed, Apr 12, 2017 at 11:08 AM, Sergi Vladykin <se...@gmail.com>
wrote:
> Looks like a bug to me.
>
> Sergi
>
> 2017-04-12 21:03 GMT+03:00 Дмитрий Рябов <so...@gmail.com>:
>
> > Why not? I do something with cache inside transaction. The only reason to
> > not rollback is another node?
> >
> > 2017-04-12 19:52 GMT+03:00 Andrey Mashenkov <andrey.mashenkov@gmail.com
> >:
> >
> > > Hi Dmitry,
> > >
> > > Looks like you start transaction on node "grid(0)", but update value on
> > > another node "grid(1)".
> > > So, technically, it is not nested transactions, right?
> > >
> > > On Wed, Apr 12, 2017 at 7:32 PM, Дмитрий Рябов <so...@gmail.com>
> > > wrote:
> > >
> > > > Hello, igniters. I start the node and create a transactional cache on
> > it,
> > > > on the other node I start the transaction and "put" in previously
> > created
> > > > cache and rollback transaction. So what should I get? Value stored
> > before
> > > > transaction or inside rolled transaction?
> > > >
> > > > public void testRollback() throws Exception {
> > > > startGrid(0);
> > > > startGrid(1);
> > > > IgniteCache<Integer, Integer> cache1 = grid( 1).cache(null);
> > > > cache1.put(1, 1);
> > > > try (Transaction tx = grid(0).transactions().
> txStart(PESSIMISTIC,
> > > READ_COMMITTED)) {
> > > > cache1.put(1, 1111);
> > > > tx.rollback();
> > > > }
> > > > assertEquals((Integer) 1, cache1.get(1));
> > > > }
> > > >
> > > >
> > > > The question is why I got 1111 instead of 1? If it is right
> behaviour -
> > > > why it nowhere explained?
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Best regards,
> > > Andrey V. Mashenkov
> > >
> >
>
Re: Question about cache and transaction on different nodes
Posted by Sergi Vladykin <se...@gmail.com>.
Looks like a bug to me.
Sergi
2017-04-12 21:03 GMT+03:00 Дмитрий Рябов <so...@gmail.com>:
> Why not? I do something with cache inside transaction. The only reason to
> not rollback is another node?
>
> 2017-04-12 19:52 GMT+03:00 Andrey Mashenkov <an...@gmail.com>:
>
> > Hi Dmitry,
> >
> > Looks like you start transaction on node "grid(0)", but update value on
> > another node "grid(1)".
> > So, technically, it is not nested transactions, right?
> >
> > On Wed, Apr 12, 2017 at 7:32 PM, Дмитрий Рябов <so...@gmail.com>
> > wrote:
> >
> > > Hello, igniters. I start the node and create a transactional cache on
> it,
> > > on the other node I start the transaction and "put" in previously
> created
> > > cache and rollback transaction. So what should I get? Value stored
> before
> > > transaction or inside rolled transaction?
> > >
> > > public void testRollback() throws Exception {
> > > startGrid(0);
> > > startGrid(1);
> > > IgniteCache<Integer, Integer> cache1 = grid( 1).cache(null);
> > > cache1.put(1, 1);
> > > try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC,
> > READ_COMMITTED)) {
> > > cache1.put(1, 1111);
> > > tx.rollback();
> > > }
> > > assertEquals((Integer) 1, cache1.get(1));
> > > }
> > >
> > >
> > > The question is why I got 1111 instead of 1? If it is right behaviour -
> > > why it nowhere explained?
> > >
> > >
> > >
> >
> >
> > --
> > Best regards,
> > Andrey V. Mashenkov
> >
>
Re: Question about cache and transaction on different nodes
Posted by Дмитрий Рябов <so...@gmail.com>.
Why not? I do something with cache inside transaction. The only reason to
not rollback is another node?
2017-04-12 19:52 GMT+03:00 Andrey Mashenkov <an...@gmail.com>:
> Hi Dmitry,
>
> Looks like you start transaction on node "grid(0)", but update value on
> another node "grid(1)".
> So, technically, it is not nested transactions, right?
>
> On Wed, Apr 12, 2017 at 7:32 PM, Дмитрий Рябов <so...@gmail.com>
> wrote:
>
> > Hello, igniters. I start the node and create a transactional cache on it,
> > on the other node I start the transaction and "put" in previously created
> > cache and rollback transaction. So what should I get? Value stored before
> > transaction or inside rolled transaction?
> >
> > public void testRollback() throws Exception {
> > startGrid(0);
> > startGrid(1);
> > IgniteCache<Integer, Integer> cache1 = grid( 1).cache(null);
> > cache1.put(1, 1);
> > try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC,
> READ_COMMITTED)) {
> > cache1.put(1, 1111);
> > tx.rollback();
> > }
> > assertEquals((Integer) 1, cache1.get(1));
> > }
> >
> >
> > The question is why I got 1111 instead of 1? If it is right behaviour -
> > why it nowhere explained?
> >
> >
> >
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>
Re: Question about cache and transaction on different nodes
Posted by Andrey Mashenkov <an...@gmail.com>.
Hi Dmitry,
Looks like you start transaction on node "grid(0)", but update value on
another node "grid(1)".
So, technically, it is not nested transactions, right?
On Wed, Apr 12, 2017 at 7:32 PM, Дмитрий Рябов <so...@gmail.com>
wrote:
> Hello, igniters. I start the node and create a transactional cache on it,
> on the other node I start the transaction and "put" in previously created
> cache and rollback transaction. So what should I get? Value stored before
> transaction or inside rolled transaction?
>
> public void testRollback() throws Exception {
> startGrid(0);
> startGrid(1);
> IgniteCache<Integer, Integer> cache1 = grid( 1).cache(null);
> cache1.put(1, 1);
> try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
> cache1.put(1, 1111);
> tx.rollback();
> }
> assertEquals((Integer) 1, cache1.get(1));
> }
>
>
> The question is why I got 1111 instead of 1? If it is right behaviour -
> why it nowhere explained?
>
>
>
--
Best regards,
Andrey V. Mashenkov