-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Duplicate cache events
PostPosted: Tue Oct 21, 2008 8:38 am 
Newbie

Joined: Tue Oct 21, 2008 8:14 am
Posts: 3
Location: London
Hi,

I've tried to search forums for this problem, but couldn't find any similarities. Hopefully anyone could lead me where do I need to start digging.

We are using Hibernate (v3.2.4ga), Spring (v2.5.5) and OSCache (v2.4).

The actual problem I've noticed is that when an entity is saved, cache is flushed twice. This wouldn't be a big problem on a single server, however it adds significant overhead in the clustered environment where we have to broadcast these events and every redundant byte is a no-no.

Below are two stack traces: both occur upon editing same entity. The key difference here (as I understand) is the
Quote:
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)

and
Quote:
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:119)

from where the cache flush routines are called.

Here go both full stack traces:
First:
Quote:
vyre.core.cache.oscache.CacheBroadcaster.sendNotification(CacheBroadcaster.java:32)
at com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener.cacheEntryFlushed(AbstractBroadcastingListener.java:49)
at com.opensymphony.oscache.base.Cache.dispatchCacheEntryEvent(Cache.java:856)
at com.opensymphony.oscache.base.Cache.flushEntry(Cache.java:982)
at com.opensymphony.oscache.base.Cache.flushEntry(Cache.java:491)
at com.opensymphony.oscache.base.Cache.flushEntry(Cache.java:478)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.flushEntry(GeneralCacheAdministrator.java:216)
at vyre.core.cache.oscache.OSCache.remove(OSCache.java:91)
at org.hibernate.cache.NonstrictReadWriteCache.evict(NonstrictReadWriteCache.java:119)
at org.hibernate.cache.NonstrictReadWriteCache.update(NonstrictReadWriteCache.java:133)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:154)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1,000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy50.create(Unknown Source:-1)


Second:
Quote:
vyre.core.cache.oscache.CacheBroadcaster.sendNotification(CacheBroadcaster.java:32)
at com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener.cacheEntryFlushed(AbstractBroadcastingListener.java:49)
at com.opensymphony.oscache.base.Cache.dispatchCacheEntryEvent(Cache.java:856)
at com.opensymphony.oscache.base.Cache.flushEntry(Cache.java:982)
at com.opensymphony.oscache.base.Cache.flushEntry(Cache.java:491)
at com.opensymphony.oscache.base.Cache.flushEntry(Cache.java:478)
at com.opensymphony.oscache.general.GeneralCacheAdministrator.flushEntry(GeneralCacheAdministrator.java:216)
at vyre.core.cache.oscache.OSCache.remove(OSCache.java:91)
at org.hibernate.cache.NonstrictReadWriteCache.release(NonstrictReadWriteCache.java:145)
at org.hibernate.cache.NonstrictReadWriteCache.afterUpdate(NonstrictReadWriteCache.java:152)
at org.hibernate.action.EntityUpdateAction.afterTransactionCompletion(EntityUpdateAction.java:240)
at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:198)
at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:424)
at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:229)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:119)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy50.create(Unknown Source:-1)


I'd be more than glad if anyone could explain me whether this is normal and how to avoid this. Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2008 8:56 am 
Newbie

Joined: Tue Oct 21, 2008 8:14 am
Posts: 3
Location: London
It's a pity that no one had discovered this problem before :(

However, I was able to pinpoint this problem to a single class in Hibernate. Basically we speak about org.hibernate.cache.NonstrictReadWriteCache, specifically about its update( Object, Object, Object, Object ) and afterUpdate( Object, Object, Object, SoftLock) methods.

So when update(...) is called, entry is flushed from the cache. Same happens inside afterUpdate(...). Javadoc above afterUpdate method says:

Quote:
/**
* Invalidate the item (again, for safety).
*/


Is it really necessary? Was there a use case for that? Should I report a bug?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.