Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Inefficient Infinispan cache invalidation for bulk operation
PostPosted: Mon Oct 16, 2017 11:20 am 
Newbie

Joined: Fri May 29, 2009 4:02 am
Posts: 4
Hi,

We recently switched from EHcache to Infinispan for our second level cache and noticed that cache invalidation is very inefficient for bulk operations (JPA CriteriaUpdate/CriteriaDelete). Rather than broadcasting a clear to all nodes in the cluster, the cache is cleared entry by entry. As entity caches are invalidating caches by default, this requires a query to all remote nodes first to collect all keys. These keys are then bundled in a very large message and sent out to all nodes again. During this entire procedure, it seems the cache region is locked on all nodes, causing the entire cluster to stall (I presume this is needed to prevent inserts into the cache between the query and the invalidation phase).

We are seeing this behavior on WildFly 10.1.0, 11.0.0.CR1 and 11 master. The correspoding code in Hibernate is:
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/InvalidationCacheAccessDelegate.java#L144 and
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/util/Caches.java#L280

Is there any way to improve upon this? The current implementation makes it impossible to perform batch operations on large cache regions with tens of thousands of entries spanning multiple nodes without blocking the entire cluster for many seconds, even up to a minute. On some places we can change the code to update the entries one by one. However, in other places this will result in thousands of queries to the database in stead of 1, making it far from ideal.

Best regards,
Emond Papegaaij


Top
 Profile  
 
 Post subject: Re: Inefficient Infinispan cache invalidation for bulk operation
PostPosted: Mon Oct 16, 2017 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1516
You should open a new Jira issue. Thanks.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Inefficient Infinispan cache invalidation for bulk operation
PostPosted: Tue Oct 17, 2017 3:20 am 
Newbie

Joined: Fri May 29, 2009 4:02 am
Posts: 4
I've opened bug reports at Hibernate and Infinispan:
https://hibernate.atlassian.net/browse/HHH-12036
https://issues.jboss.org/browse/ISPN-8411


Top
 Profile  
 
 Post subject: Re: Inefficient Infinispan cache invalidation for bulk operation
PostPosted: Tue Oct 17, 2017 3:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1516
Thank you.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Inefficient Infinispan cache invalidation for bulk operation
PostPosted: Mon Oct 30, 2017 10:05 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1516
HHH-12036 is fixed now.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.