[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4577?page=c...
]
Guenther Demetz commented on HHH-4577:
--------------------------------------
Now in Hibernate3.5.0Beta3 the issue is resolved for the invalidate calls.
But for the pre-invalidate calls the problem persists!
Please see following log-output (made using Infinispan4.0.0CR3 as 2lcache-impl)
and note :
13:52:10,619 INFO Environment:563 - Hibernate 3.5.0-Beta-3
...
13:52:18,543 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,552 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,555 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,557 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,559 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,560 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,562 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,563 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,564 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,565 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,569 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,571 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,573 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,574 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,578 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,579 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,581 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,582 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,584 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,586 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,586 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,587 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,587 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,588 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,588 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,589 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,590 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,590 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,593 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
13:52:18,594 DEBUG UpdateTimestampsCache:66 - Pre-invalidating space [PersonInCharge]
...
13:52:18,626 DEBUG UpdateTimestampsCache:81 - Invalidating space [PersonInCharge],
timestamp: 5176603191803911
2L query cache: Low performance of flush and commit due many
unnecessary (pre)invalidate calls on UpdateTimestampsCache
-----------------------------------------------------------------------------------------------------------------------
Key: HHH-4577
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4577
Project: Hibernate Core
Issue Type: Improvement
Components: caching (L2)
Affects Versions: 3.3.2
Environment: Hibernate 3.3.2GA with JBossCache3.2.1.GA as 2L-cache provider
SQLServer2008
Reporter: Guenther Demetz
Attachments: Hibernate3_3_2_ActionQueue_patch.jar,
Hibernate3_3_2_ActionQueue_patch.jar
Analyzing what our application is mainly doing during flush/commit,
we saw that very often the concerning thread is executing in jbosscache stuff (see 2
sample stacktraces below).
Analyzing the code we discovered that, if doing 1000 inserts for a determinate entity:
-on flush UpdateTimestampsCache.preinvalidate() is called 1000 times for the same space
(=table)
-on commit UpdateTimestampsCache.invalidate() is called another 1000 times again for the
same space (=table)
It would be much smarter to collect the interested spaces once per flush and once per
commit and then execute the (pre)invalidate once per single space. In the case above it
would reduce the calls to one single UpdateTimestampsCache.preinvalidate()call on flush
and one single UpdateTimestampsCache.invalidate() on commit.
For the commit the enhancement could be following:
ActionQueue.java:
public void afterTransactionCompletion(boolean success) {
int size = executions.size();
final boolean invalidateQueryCache =
session.getFactory().getSettings().isQueryCacheEnabled();
Set<Serializable> spaces = invalidateQueryCache ? new
HashSet<Serializable>() : null;
try {
for ( int i = 0; i < size; i++ ) {
try {
Executable exec = ( Executable ) executions.get( i );
if ( invalidateQueryCache ) {
Serializable[] nspaces = exec.getPropertySpaces();
for (int j=0; j < nspaces.length; j++)
spaces.add(nspaces[j]);
}
exec.afterTransactionCompletion( success );
}
catch ( CacheException ce ) {
log.error( "could not release a cache lock", ce );
// continue loop
}
catch ( Exception e ) {
throw new AssertionFailure( "Exception releasing cache locks", e );
}
}
}
finally {
session.getFactory().getUpdateTimestampsCache().invalidate(spaces.toArray(new
Serializable[]{}));
}
executions.clear();
}
Stack traces:
java.lang.Thread.isInterrupted(Native Method)
java.lang.Thread.interrupted(Thread.java:873)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1134)
java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:312)
java.util.concurrent.LinkedBlockingQueue.put(LinkedBlockingQueue.java:241)
org.jboss.cache.RegionImpl.registerEvictionEvent(RegionImpl.java:249)
org.jboss.cache.RegionImpl.registerEvictionEvent(RegionImpl.java:234)
org.jboss.cache.interceptors.EvictionInterceptor.registerEvictionEventToRegionManager(EvictionInterceptor.java:252)
org.jboss.cache.interceptors.EvictionInterceptor.visitPutKeyValueCommand(EvictionInterceptor.java:109)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.MVCCLockingInterceptor.handlePutKeyValueCommand(MVCCLockingInterceptor.java:102)
org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor.visitPutKeyValueCommand(PrePostProcessingCommandInterceptor.java:88)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
org.jboss.cache.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:65)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.TxInterceptor.attachGtxAndPassUpChain(TxInterceptor.java:301)
org.jboss.cache.interceptors.TxInterceptor.handleDefault(TxInterceptor.java:283)
org.jboss.cache.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:65)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.CacheMgmtInterceptor.visitPutKeyValueCommand(CacheMgmtInterceptor.java:119)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:178)
org.jboss.cache.interceptors.InvocationContextInterceptor.visitPutKeyValueCommand(InvocationContextInterceptor.java:82)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.InterceptorChain.invoke(InterceptorChain.java:287)
org.jboss.cache.invocation.CacheInvocationDelegate.put(CacheInvocationDelegate.java:555)
org.hibernate.cache.jbc2.util.CacheHelper.put(CacheHelper.java:212)
org.hibernate.cache.jbc2.timestamp.TimestampsRegionImpl.put(TimestampsRegionImpl.java:128)
org.hibernate.cache.UpdateTimestampsCache.preinvalidate(UpdateTimestampsCache.java:70)
- locked org.hibernate.cache.UpdateTimestampsCache@1afcaae
org.hibernate.engine.ActionQueue.execute(ActionQueue.java:275)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
Stack trace:
java.lang.Thread.isInterrupted(Native Method)
java.lang.Thread.interrupted(Thread.java:873)
java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireNanos(AbstractQueuedSynchronizer.java:1158)
java.util.concurrent.locks.ReentrantLock.tryLock(ReentrantLock.java:416)
org.jboss.cache.util.concurrent.locks.AbstractSharedLockContainer.acquireLock(AbstractSharedLockContainer.java:94)
org.jboss.cache.lock.MVCCLockManager.lockAndRecord(MVCCLockManager.java:133)
org.jboss.cache.mvcc.MVCCNodeHelper.acquireLock(MVCCNodeHelper.java:157)
org.jboss.cache.mvcc.MVCCNodeHelper.wrapNodeForWriting(MVCCNodeHelper.java:217)
org.jboss.cache.mvcc.MVCCNodeHelper.wrapNodeForWriting(MVCCNodeHelper.java:186)
org.jboss.cache.interceptors.MVCCLockingInterceptor.handlePutKeyValueCommand(MVCCLockingInterceptor.java:101)
org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor.visitPutKeyValueCommand(PrePostProcessingCommandInterceptor.java:88)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:131)
org.jboss.cache.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:65)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.TxInterceptor.attachGtxAndPassUpChain(TxInterceptor.java:301)
org.jboss.cache.interceptors.TxInterceptor.handleDefault(TxInterceptor.java:283)
org.jboss.cache.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:65)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.CacheMgmtInterceptor.visitPutKeyValueCommand(CacheMgmtInterceptor.java:119)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:116)
org.jboss.cache.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:178)
org.jboss.cache.interceptors.InvocationContextInterceptor.visitPutKeyValueCommand(InvocationContextInterceptor.java:82)
org.jboss.cache.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:100)
org.jboss.cache.interceptors.InterceptorChain.invoke(InterceptorChain.java:287)
org.jboss.cache.invocation.CacheInvocationDelegate.put(CacheInvocationDelegate.java:555)
org.hibernate.cache.jbc2.util.CacheHelper.put(CacheHelper.java:212)
org.hibernate.cache.jbc2.timestamp.TimestampsRegionImpl.put(TimestampsRegionImpl.java:128)
org.hibernate.cache.UpdateTimestampsCache.invalidate(UpdateTimestampsCache.java:85)
- locked org.hibernate.cache.UpdateTimestampsCache@1afcaae
org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:202)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira