More fussing with lookup cache. It seems a hair faster.

Some cleanup of the retrying transaction stuff.
Minor mods to one stress test to account for changes to retrying
transactions.  


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4616 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-12-15 06:42:50 +00:00
parent 8c777dbb94
commit d9a20c4e55
6 changed files with 214 additions and 86 deletions

View File

@@ -5,7 +5,6 @@ package org.alfresco.repo.transaction;
import java.util.Random;
import org.alfresco.error.AlfrescoRuntimeException;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Logger;
@@ -104,37 +103,44 @@ public class RetryingTransactionAdvice implements MethodInterceptor
}
return result;
}
catch (Throwable e)
catch (RuntimeException e)
{
if (txn != null && isNewTxn && !txn.isCompleted())
{
fTxnManager.rollback(txn);
}
if (e instanceof ConcurrencyFailureException ||
e instanceof DeadlockLoserDataAccessException ||
e instanceof StaleObjectStateException ||
e instanceof LockAcquisitionException)
if (!isNewTxn)
{
if (!isNewTxn)
throw e;
}
lastException = e;
Throwable t = e;
boolean shouldRetry = false;
while (t != null)
{
if (t instanceof ConcurrencyFailureException ||
t instanceof DeadlockLoserDataAccessException ||
t instanceof StaleObjectStateException ||
t instanceof LockAcquisitionException)
{
throw (RuntimeException)e;
}
lastException = (RuntimeException)e;
try
{
Thread.sleep(fRandom.nextInt(500 * count + 500));
}
catch (InterruptedException ie)
{
// Do nothing.
shouldRetry = true;
try
{
Thread.sleep(fRandom.nextInt(500 * count + 500));
}
catch (InterruptedException ie)
{
// Do nothing.
}
break;
}
t = t.getCause();
}
if (shouldRetry)
{
continue;
}
if (e instanceof RuntimeException)
{
throw (RuntimeException)e;
}
throw new AlfrescoRuntimeException("Failure in Transaction.", e);
throw e;
}
}
fgLogger.error("Txn Failed after " + fMaxRetries + " retries:", lastException);

View File

@@ -5,7 +5,6 @@ package org.alfresco.repo.transaction;
import java.util.Random;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
@@ -159,30 +158,35 @@ public class RetryingTransactionHelper
throw new AlfrescoRuntimeException("Failure during rollback.", e1);
}
}
// This handles the case of an unexpected rollback in
// the UserTransaction.
if (e instanceof RollbackException)
lastException = (e instanceof RuntimeException) ?
(RuntimeException)e : new AlfrescoRuntimeException("Unknown Exception in Transaction.", e);
Throwable t = e;
boolean shouldRetry = false;
while (t != null)
{
RollbackException re = (RollbackException)e;
e = re.getCause();
// These are the 'OK' exceptions. These mean we can retry.
if (t instanceof ConcurrencyFailureException ||
t instanceof DeadlockLoserDataAccessException ||
t instanceof StaleObjectStateException ||
t instanceof LockAcquisitionException)
{
shouldRetry = true;
// Sleep a random amount of time before retrying.
// The sleep interval increases with the number of retries.
try
{
Thread.sleep(fRandom.nextInt(500 * count + 500));
}
catch (InterruptedException ie)
{
// Do nothing.
}
break;
}
t = t.getCause();
}
// These are the 'OK' exceptions. These mean we can retry.
if (e instanceof ConcurrencyFailureException ||
e instanceof DeadlockLoserDataAccessException ||
e instanceof StaleObjectStateException ||
e instanceof LockAcquisitionException)
if (shouldRetry)
{
lastException = (RuntimeException)e;
// Sleep a random amount of time before retrying.
// The sleep interval increases with the number of retries.
try
{
Thread.sleep(fRandom.nextInt(500 * count + 500));
}
catch (InterruptedException ie)
{
// Do nothing.
}
continue;
}
// It was a 'bad' exception.