You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by schernolys <se...@gmail.com> on 2017/09/20 09:52:24 UTC

Problem with transactions in Apache Ignite!

Hi!
I am use of contributors of project "Hibernate OGM". I am preparing my PR
for the project.
I have a question.
Problem is that part of tests is failed after migration from Ignite 1.9 to
Ignite 2.1. These tests uses one feature (session.flush()).
____________________
                em.getTransaction().begin();
                Poem poem = new Poem();
                poem.setName("L'albatros");
                em.persist(poem);
                em.getTransaction().commit();
                em.clear();
                em.getTransaction().begin();
                Poem poem2 = new Poem();
                poem2.setName("Wazaaaaa");
                em.persist(poem2);
                em.flush(); //*data not flushed to Ignite's cache*
               
Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(2L);
                em.getTransaction().rollback();
               
Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(1L);
____________________

Please comment situation with em.flush()




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Problem with transactions in Apache Ignite!

Posted by Denis Mekhanikov <dm...@gmail.com>.
I found this thread that contains discussion of a similar problem:
http://apache-ignite-users.70518.x6.nabble.com/Ignite-Transactions-and-non-committed-entries-td6451.html
Size is simply not a transactional operation and it is not guaranteed the
value returned from it will be consistent with ongoing transactions. So
aparently it is not a bug.

Denis

ср, 20 сент. 2017 г. в 17:37, Denis Mekhanikov <dm...@gmail.com>:

> Sergey!
>
> After offline discussion I managed to reproduce your problem.
> It seems that IgniteCache.size(...) doesn't take into account changes made
> during ongoing transaction.
>
> It looks like a bug to me. I'll try to figure out what behavior is
> expected here and whether it is a known issue.
> Maybe it is worth to file a ticket in JIRA.
>
> For now you may check whether records are written to cache by using
> Cache.get(...) method instead of checking the size.
> Make sure to invoke get(...) in the thread that started the transaction,
> otherwise you risk to get a deadlock.
>
> Denis
>
> ср, 20 сент. 2017 г. в 16:23, Denis Mekhanikov <dm...@gmail.com>:
>
>> Hi!
>>
>> Could you please provide a pure Ignite reproducer that won't involve
>> Hibernate OGM?
>> Right now it's hard to tell whether the problem is in Ignite or in
>> Hibernate.
>>
>> Thanks!
>> Denis
>>
>> ср, 20 сент. 2017 г. в 12:52, schernolys <se...@gmail.com>:
>>
>>> Hi!
>>> I am use of contributors of project "Hibernate OGM". I am preparing my PR
>>> for the project.
>>> I have a question.
>>> Problem is that part of tests is failed after migration from Ignite 1.9
>>> to
>>> Ignite 2.1. These tests uses one feature (session.flush()).
>>> ____________________
>>>                 em.getTransaction().begin();
>>>                 Poem poem = new Poem();
>>>                 poem.setName("L'albatros");
>>>                 em.persist(poem);
>>>                 em.getTransaction().commit();
>>>                 em.clear();
>>>                 em.getTransaction().begin();
>>>                 Poem poem2 = new Poem();
>>>                 poem2.setName("Wazaaaaa");
>>>                 em.persist(poem2);
>>>                 em.flush(); //*data not flushed to Ignite's cache*
>>>
>>> Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(2L);
>>>                 em.getTransaction().rollback();
>>>
>>> Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(1L);
>>> ____________________
>>>
>>> Please comment situation with em.flush()
>>>
>>>
>>>
>>>
>>> --
>>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>>
>>

Re: Problem with transactions in Apache Ignite!

Posted by Denis Mekhanikov <dm...@gmail.com>.
Sergey!

After offline discussion I managed to reproduce your problem.
It seems that IgniteCache.size(...) doesn't take into account changes made
during ongoing transaction.

It looks like a bug to me. I'll try to figure out what behavior is expected
here and whether it is a known issue.
Maybe it is worth to file a ticket in JIRA.

For now you may check whether records are written to cache by using
Cache.get(...) method instead of checking the size.
Make sure to invoke get(...) in the thread that started the transaction,
otherwise you risk to get a deadlock.

Denis

ср, 20 сент. 2017 г. в 16:23, Denis Mekhanikov <dm...@gmail.com>:

> Hi!
>
> Could you please provide a pure Ignite reproducer that won't involve
> Hibernate OGM?
> Right now it's hard to tell whether the problem is in Ignite or in
> Hibernate.
>
> Thanks!
> Denis
>
> ср, 20 сент. 2017 г. в 12:52, schernolys <se...@gmail.com>:
>
>> Hi!
>> I am use of contributors of project "Hibernate OGM". I am preparing my PR
>> for the project.
>> I have a question.
>> Problem is that part of tests is failed after migration from Ignite 1.9 to
>> Ignite 2.1. These tests uses one feature (session.flush()).
>> ____________________
>>                 em.getTransaction().begin();
>>                 Poem poem = new Poem();
>>                 poem.setName("L'albatros");
>>                 em.persist(poem);
>>                 em.getTransaction().commit();
>>                 em.clear();
>>                 em.getTransaction().begin();
>>                 Poem poem2 = new Poem();
>>                 poem2.setName("Wazaaaaa");
>>                 em.persist(poem2);
>>                 em.flush(); //*data not flushed to Ignite's cache*
>>
>> Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(2L);
>>                 em.getTransaction().rollback();
>>
>> Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(1L);
>> ____________________
>>
>> Please comment situation with em.flush()
>>
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>

Re: Problem with transactions in Apache Ignite!

Posted by Denis Mekhanikov <dm...@gmail.com>.
Hi!

Could you please provide a pure Ignite reproducer that won't involve
Hibernate OGM?
Right now it's hard to tell whether the problem is in Ignite or in
Hibernate.

Thanks!
Denis

ср, 20 сент. 2017 г. в 12:52, schernolys <se...@gmail.com>:

> Hi!
> I am use of contributors of project "Hibernate OGM". I am preparing my PR
> for the project.
> I have a question.
> Problem is that part of tests is failed after migration from Ignite 1.9 to
> Ignite 2.1. These tests uses one feature (session.flush()).
> ____________________
>                 em.getTransaction().begin();
>                 Poem poem = new Poem();
>                 poem.setName("L'albatros");
>                 em.persist(poem);
>                 em.getTransaction().commit();
>                 em.clear();
>                 em.getTransaction().begin();
>                 Poem poem2 = new Poem();
>                 poem2.setName("Wazaaaaa");
>                 em.persist(poem2);
>                 em.flush(); //*data not flushed to Ignite's cache*
>
> Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(2L);
>                 em.getTransaction().rollback();
>
> Assertions.assertThat(TestHelper.getNumberOfEntities(em)).isEqualTo(1L);
> ____________________
>
> Please comment situation with em.flush()
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>