Merged V2.9 to HEAD

9018: MT: system-wide jobs should run across all stores/indexes
   9204: Merged V2.2 to V2.9
      8633: Merged V2.1 to V2.2
         8629: Merged V2.1-A to V2.1
            8493: Fixed ADB-51: ImporterBootstrap doesn't use transaction retrying
            8494: EHCache and JGroup patches and upgrades
            8546: ACT-1650: performance optimization
            8550: Fixes to transactional cache handling
            8553: Fixed tests: MLText is a Map, but will always have at least one entry, even that entry is null.
            8583: ACT-954: IndexInfo files now reopen when they close (for whatever reason)
      8640: Merged V2.1 to V2.2
         8638: Used correct exception type for IO channel reopen logic
      9102: Unit test to check that transactional cache size overrun is handled
      9106: Merged V2.1 to V2.2
         9043: Fixed AR-2291: SchemaBootstrap lock is only required before first SQL execution
         9045: Fix AR-2291: SchemaBootstrap lock is only required before first SQL execution
         9047: Fixed AR-2305: Index tracking in AUTO mode doesn't report anything on bootstrap
         9048: Fixed AR-2300: Random-based GUID instead of time-based GUIDs
         9049: Fix patches to only run once
         9050 <Defered>: Changed getString() method to use the available buffer length rather than a hard coded value.
         9060: Fixed ETWOONE-109 and ETWOONE-128: RetryingTransactionHelper fixes and improvements
         9061: Fixed NodeRefPropertyMethodInterceptorTest
         9075 <Defered>: Added delete permission check when marking a file for delete on close. ETWOONE-141/ACT-2416.
         9080: Fixed EHCache source zip
         9081: Fixed ETWOONE-118: Tomcat failed bootstrap doesn't clean up EHCache cluster structures
         9085: Fixed ETWOONE-154: Added JSR107 Jar to WAR
      9115: Fixed test: TransactionalCache uses LRU so repeatedly checking if a entry is there keeps it in the cache.
   9206: Merged V2.2 to V2.9
      8857: Improvements to ACL performance for large ACLs
      8951: Always check permission entry changes are made at position 0
   9219 <No change>: Made NTLMLogonDetails class Serializable, port of r8973.
   9220: Added delete permission check when marking a file for delete on close. Port of r9075.
   9222: Merged V2.1 to V2.9
      8683: Early warning for nodes indexed in the wrong store (ACT-964)
      8684: Enhanced tests
      8685: Enhanced tests
      8686: Additional tests
   9223: Merged V2.2 to V2.9
      9120: Merged V2.1 to V2.2
         8740: Fix for AR-2173 - do no recheck case of the user name when validating tickets (it has been done)
      9122: Additional unit test from support case.
   9224: Merged V2.2 to V2.9
      9076: Fixed ETWOTWO-426: Upgrading alfresco from 2.1.1 to 2.2 throws errors with Mysql 5.0.51
      9104: Merged V2.1 to V2.2
         9025: Fixed AR-2314, AR-2299: Optimizations after profiling
      9105: Merged V2.1 to V2.2
         8745: Fix AR-2233 (regression introduced by fix for AR-2221)
      9121: Merged V2.1 to V2.2
         9017: Fix index back up failing due to background index merge/deletions (inlcudes back port of CHK-2588)
      9137: Incorporated additions from Will into AVM console (ETWOTWO-439)
   9225: Merged V2.1 to V2.9
      8641: Merged V2.1-A to V2.1
         7729: Fix to Repository Web Service (queryAssociated) to allow reverse association lookup (ie. given target, get the source)
      8673: Fix for AR-2098 - shorter URL form now has NTLM filter mapping example in web.xml
      8682: Fix for AR-2005
      8695: AR-2054.
      8696: Improved sort test to include prefix form of field name
   9226: Fix ALFCOM-994 (see also earlier change in r9223)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9233 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-05-22 12:40:46 +00:00
parent 86027f41f1
commit 6e225ce15d
60 changed files with 2359 additions and 1164 deletions

View File

@@ -24,6 +24,7 @@
*/
package org.alfresco.repo.transaction;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -33,6 +34,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.cache.TransactionalCache;
import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.search.impl.lucene.LuceneIndexerAndSearcher;
import org.alfresco.util.GUID;
@@ -319,7 +321,7 @@ public abstract class AlfrescoTransactionSupport
TransactionSynchronizationImpl synch = getSynchronization();
// bind the service in
boolean bound = synch.getListeners().add(listener);
boolean bound = synch.addListener(listener);
// done
if (logger.isDebugEnabled())
@@ -387,7 +389,8 @@ public abstract class AlfrescoTransactionSupport
*/
if (!TransactionSynchronizationManager.isSynchronizationActive())
{
throw new AlfrescoRuntimeException("Transaction must be active and synchronization is required");
Thread currentThread = Thread.currentThread();
throw new AlfrescoRuntimeException("Transaction must be active and synchronization is required: " + currentThread);
}
TransactionSynchronizationImpl txnSynch =
(TransactionSynchronizationImpl) TransactionSynchronizationManager.getResource(RESOURCE_KEY_TXN_SYNCH);
@@ -453,6 +456,8 @@ public abstract class AlfrescoTransactionSupport
private final Set<IntegrityChecker> integrityCheckers;
private final Set<LuceneIndexerAndSearcher> lucenes;
private final LinkedHashSet<TransactionListener> listeners;
private final Set<TransactionalCache<Serializable, Object>> transactionalCaches;
// private final Set<JGroupsEhCacheListener> jgroupsEhCacheListeners;
private final Map<Object, Object> resources;
/**
@@ -468,6 +473,8 @@ public abstract class AlfrescoTransactionSupport
integrityCheckers = new HashSet<IntegrityChecker>(3);
lucenes = new HashSet<LuceneIndexerAndSearcher>(3);
listeners = new LinkedHashSet<TransactionListener>(5);
transactionalCaches = new HashSet<TransactionalCache<Serializable, Object>>(3);
// jgroupsEhCacheListeners = new HashSet<JGroupsEhCacheListener>(3);
resources = new HashMap<Object, Object>(17);
}
@@ -512,9 +519,21 @@ public abstract class AlfrescoTransactionSupport
* @return Returns a set of <tt>TransactionListener<tt> instances that will be called
* during end-of-transaction processing
*/
public Set<TransactionListener> getListeners()
@SuppressWarnings("unchecked")
public boolean addListener(TransactionListener listener)
{
return listeners;
if (listener instanceof TransactionalCache)
{
return transactionalCaches.add((TransactionalCache<Serializable, Object>)listener);
}
// else if (listener instanceof JGroupsEhCacheListener)
// {
// return jgroupsEhCacheListeners.add((JGroupsEhCacheListener)listener);
// }
else
{
return listeners.add(listener);
}
}
/**
@@ -608,6 +627,18 @@ public abstract class AlfrescoTransactionSupport
{
dao.beforeCommit();
}
// Flush the transactional caches
for (TransactionalCache<Serializable, Object> cache : transactionalCaches)
{
cache.beforeCommit(readOnly);
}
//
// // Flush the JGroups listeners
// for (JGroupsEhCacheListener listener : jgroupsEhCacheListeners)
// {
// listener.beforeCommit(readOnly);
// }
}
/**
@@ -621,7 +652,9 @@ public abstract class AlfrescoTransactionSupport
}
/**
* Executes the beforeCommit event handlers for the outstanding listeners
* Executes the beforeCommit event handlers for the outstanding listeners.
* This process is iterative as the process of calling listeners may lead to more listeners
* being added. The new listeners will be processed until there no listeners remaining.
*
* @param visitedListeners a set containing the already visited listeners
* @param readOnly is read only

View File

@@ -25,13 +25,15 @@
package org.alfresco.repo.transaction;
import java.sql.BatchUpdateException;
import java.sql.SQLException;
import java.util.Random;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import net.sf.ehcache.distribution.RemoteCacheException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.error.ExceptionStackUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -63,6 +65,7 @@ public class RetryingTransactionHelper
/**
* Exceptions that trigger retries.
*/
@SuppressWarnings("unchecked")
public static final Class[] RETRY_EXCEPTIONS;
static
{
@@ -71,11 +74,14 @@ public class RetryingTransactionHelper
DeadlockLoserDataAccessException.class,
StaleObjectStateException.class,
LockAcquisitionException.class,
BatchUpdateException.class,
ConstraintViolationException.class,
UncategorizedSQLException.class,
SQLException.class,
BatchUpdateException.class,
DataIntegrityViolationException.class,
StaleStateException.class,
ObjectNotFoundException.class
ObjectNotFoundException.class,
RemoteCacheException.class
};
}
@@ -304,20 +310,10 @@ public class RetryingTransactionHelper
txn.rollback();
}
}
catch (IllegalStateException e1)
catch (Throwable e1)
{
logger.error(e);
throw new AlfrescoRuntimeException("Failure during rollback: " + cb, e1);
}
catch (SecurityException e1)
{
logger.error(e);
throw new AlfrescoRuntimeException("Failure during rollback: " + cb, e1);
}
catch (SystemException e1)
{
logger.error(e);
throw new AlfrescoRuntimeException("Failure during rollback: " + cb, e1);
// A rollback failure should not preclude a retry, but logging of the rollback failure is required
logger.error("Rollback failure. Normal retry behaviour will resume.", e1);
}
}
if (e instanceof RollbackException)
@@ -365,6 +361,7 @@ public class RetryingTransactionHelper
* @param cause the cause to examine
* @return Returns the original cause if it is a valid retry cause, otherwise <tt>null</tt>
*/
@SuppressWarnings("unchecked")
public static Throwable extractRetryCause(Throwable cause)
{
Throwable retryCause = ExceptionStackUtil.getCause(cause, RETRY_EXCEPTIONS);
@@ -372,57 +369,9 @@ public class RetryingTransactionHelper
{
return null;
}
else if (retryCause instanceof BatchUpdateException)
{
if (retryCause.getMessage().contains("Lock wait"))
{
// It is valid
return retryCause;
}
else
{
// Not valid
return null;
}
}
else if (retryCause instanceof DataIntegrityViolationException)
{
if (retryCause.getMessage().contains("ChildAssocImpl"))
{
// It is probably the duplicate name violation
return retryCause;
}
else
{
// Something else
return null;
}
}
else if (retryCause instanceof UncategorizedSQLException)
{
// Handle error that slips out of MSSQL
if (retryCause.getMessage().contains("deadlock"))
{
// It is valid
return retryCause;
}
else
{
// Not valid
return null;
}
}
else if (retryCause instanceof ObjectNotFoundException)
{
// This is (I'm almost certain) an optimistic locking failure in disguise.
if (retryCause.getMessage().contains("No row"))
{
return retryCause;
}
return null;
}
else
{
// A simple match
return retryCause;
}
}

View File

@@ -39,8 +39,10 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* Tests the transaction retrying behaviour with various failure modes.
@@ -309,6 +311,7 @@ public class RetryingTransactionHelperTest extends TestCase
* Checks nesting of two transactions with <code>requiresNew == true</code>,
* but where the two transactions get involved in a concurrency struggle.
*/
@SuppressWarnings("unchecked")
public void testNestedWithoutPropogationConcurrentUntilFailure()
{
RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>()
@@ -379,4 +382,41 @@ public class RetryingTransactionHelperTest extends TestCase
long checkValue = txnHelper.doInTransaction(callback);
assertEquals("Check value not incremented", 11, checkValue);
}
public void testLostConnectionRecovery()
{
RetryingTransactionCallback<Object> killConnectionCallback = new RetryingTransactionCallback<Object>()
{
private boolean killed = false;
public Object execute() throws Throwable
{
// Do some work
nodeService.deleteNode(workingNodeRef);
// Successful upon retry
if (killed)
{
return null;
}
// Kill the connection the first time
HibernateConnectionKiller killer = new HibernateConnectionKiller();
killer.setSessionFactory((SessionFactory)ctx.getBean("sessionFactory"));
killer.killConnection();
killed = true;
return null;
}
};
// This should work
txnHelper.doInTransaction(killConnectionCallback);
}
/**
* Helper class to kill the session's DB connection
*/
private class HibernateConnectionKiller extends HibernateDaoSupport
{
private void killConnection() throws Exception
{
getSession().connection().rollback();
}
}
}

View File

@@ -52,7 +52,8 @@ public interface TransactionListener
* {@link #beforeCommit(boolean) } even if {@link #beforeCommit(boolean)}
* failed.
* <p>
* Any exceptions generated here will cause the transaction to rollback.
* Any exceptions generated here will only be logged and will have no effect
* on the state of the transaction.
* <p>
* All transaction resources are still available.
*/