Fix for AR-1483: Multithreaded access to booleans via volatile access.

Made reindex logic a bit more obvious to the reader.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5861 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-06-06 08:56:27 +00:00
parent 74b2ac0c79
commit 1b24226f6b

View File

@@ -84,7 +84,7 @@ public abstract class AbstractReindexComponent implements IndexRecovery
/** the component giving direct access to <b>transaction</b> instances */ /** the component giving direct access to <b>transaction</b> instances */
protected NodeDaoService nodeDaoService; protected NodeDaoService nodeDaoService;
private boolean shutdown; private volatile boolean shutdown;
private final WriteLock indexerWriteLock; private final WriteLock indexerWriteLock;
public AbstractReindexComponent() public AbstractReindexComponent()
@@ -307,7 +307,10 @@ public abstract class AbstractReindexComponent implements IndexRecovery
} }
/** /**
* @return Returns true if the given transaction is indexed in the in the * @param updateCount the number of node updates in the transaction
* @param deleteCount the number of node deletions in the transaction
* @return Returns true if the given transaction is indexed,
* or if there are no updates or deletes
*/ */
private boolean isTxnIdPresentInIndex(StoreRef storeRef, Transaction txn, int updateCount, int deleteCount) private boolean isTxnIdPresentInIndex(StoreRef storeRef, Transaction txn, int updateCount, int deleteCount)
{ {
@@ -350,6 +353,8 @@ public abstract class AbstractReindexComponent implements IndexRecovery
if (results != null) { results.close(); } if (results != null) { results.close(); }
} }
} }
else if (deleteCount > 0)
{
// there have been deletes, so we have to ensure that none of the nodes deleted are present in the index // there have been deletes, so we have to ensure that none of the nodes deleted are present in the index
// get all node refs for the transaction // get all node refs for the transaction
List<NodeRef> nodeRefs = nodeDaoService.getTxnChangesForStore(storeRef, txnId); List<NodeRef> nodeRefs = nodeDaoService.getTxnChangesForStore(storeRef, txnId);
@@ -397,6 +402,8 @@ public abstract class AbstractReindexComponent implements IndexRecovery
if (results != null) { results.close(); } if (results != null) { results.close(); }
} }
} }
}
// else -> The fallthrough case where there are no updates or deletes
// all tests passed // all tests passed
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())