You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Milap Wadhwa (JIRA)" <ji...@apache.org> on 2016/08/04 14:32:20 UTC

[jira] [Comment Edited] (IGNITE-1084) [Test] HibernateL2CacheSelfTest#testNaturalIdCache() is broken

    [ https://issues.apache.org/jira/browse/IGNITE-1084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15407848#comment-15407848 ] 

Milap Wadhwa edited comment on IGNITE-1084 at 8/4/16 2:31 PM:
--------------------------------------------------------------

Hi [~yzhdanov],

Issue is with NONSTRICT_READ_WRITE policy in hibernate.

In case of Read_Write policy hibernate uses Optimistic Locking where NaturalId key is used as a lock. If someone is trying to update the row, hibernate will acquire the lock on the key and subsequent reads/writes for the same key will be served by DB layer and later L2 cache will get updated asynchronously and eventually will remove the lock on the key.

But in case of NonStrictReadWrite, Hibernate allows read on inconsistent key from L2 cache i.e. It does not acquire the lock. which means subsequent reads will be allowed to read from L2 cache and background process will evict the cache for the key asynchronously. 

Test case is failing because It is checking non-existence of k (NaturalId) which is correct behaviour because test case is changing k to k`
In NonStrictReadWrite L2 cache has reads for both keys k and k` because It does not have lock on k which is incorrect. 
This is not causing problem for ReadWrite because key k is always locked in L2 cache which delegate this read to db which eventually does not have key k (update with k`) and hence the test case is passing.

Solution:
problem is due to inconsistent L2 cache state in case of updating the naturalId. So, before validating the test case, wrote a utility to reload the entire L2 cache. 

I hope I have explained it properly. Please let me know If you need more info.


Regards,
Milap Wadhwa


was (Author: milap.wadhwa):
Hi Yakov,

Issue is with NONSTRICT_READ_WRITE policy in hibernate.

In case of Read_Write policy hibernate uses Optimistic Locking where NaturalId key is used as a lock. If someone is trying to update the row, hibernate will acquire the lock on the key and subsequent reads/writes for the same key will be served by DB layer and later L2 cache will get updated asynchronously and eventually will remove the lock on the key.

But in case of NonStrictReadWrite, Hibernate allows read on inconsistent key from L2 cache i.e. It does not acquire the lock. which means subsequent reads will be allowed to read from L2 cache and background process will evict the cache for the key asynchronously. 

Test case is failing because It is checking non-existence of k (NaturalId) which is correct behaviour because test case is changing k to k`
In NonStrictReadWrite L2 cache has reads for both keys k and k` because It does not have lock on k which is incorrect. 
This is not causing problem for ReadWrite because key k is always locked in L2 cache which delegate this read to db which eventually does not have key k (update with k`) and hence the test case is passing.

Solution:
problem is due to inconsistent L2 cache state in case of updating the naturalId. So, before validating the test case, wrote a utility to reload the entire L2 cache. 

I hope I have explained it properly. Please let me know If you need more info.


Regards,
Milap Wadhwa

> [Test] HibernateL2CacheSelfTest#testNaturalIdCache() is broken
> --------------------------------------------------------------
>
>                 Key: IGNITE-1084
>                 URL: https://issues.apache.org/jira/browse/IGNITE-1084
>             Project: Ignite
>          Issue Type: Test
>          Components: cache
>            Reporter: Sergey Evdokimov
>            Assignee: Milap Wadhwa
>            Priority: Minor
>              Labels: Muted_test
>
> Test HibernateL2CacheSelfTest#testNaturalIdCache() should be unmuted and fixed.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)