mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -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,53 +353,57 @@ public abstract class AbstractReindexComponent implements IndexRecovery
|
|||||||
if (results != null) { results.close(); }
|
if (results != null) { results.close(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// there have been deletes, so we have to ensure that none of the nodes deleted are present in the index
|
else if (deleteCount > 0)
|
||||||
// get all node refs for the transaction
|
|
||||||
List<NodeRef> nodeRefs = nodeDaoService.getTxnChangesForStore(storeRef, txnId);
|
|
||||||
for (NodeRef nodeRef : nodeRefs)
|
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
// 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
|
||||||
|
List<NodeRef> nodeRefs = nodeDaoService.getTxnChangesForStore(storeRef, txnId);
|
||||||
|
for (NodeRef nodeRef : nodeRefs)
|
||||||
{
|
{
|
||||||
logger.debug("Searching for node in index: \n" +
|
if (logger.isDebugEnabled())
|
||||||
" node: " + nodeRef + "\n" +
|
|
||||||
" txn: " + txnId);
|
|
||||||
}
|
|
||||||
// we know that these are all deletions
|
|
||||||
ResultSet results = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SearchParameters sp = new SearchParameters();
|
|
||||||
sp.addStore(storeRef);
|
|
||||||
// search for it in the index, sorting with youngest first, fetching only 1
|
|
||||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
|
||||||
sp.setQuery("ID:" + LuceneQueryParser.escape(nodeRef.toString()));
|
|
||||||
sp.setLimit(1);
|
|
||||||
|
|
||||||
results = searcher.query(sp);
|
|
||||||
|
|
||||||
if (results.length() == 0)
|
|
||||||
{
|
{
|
||||||
// no results, as expected
|
logger.debug("Searching for node in index: \n" +
|
||||||
if (logger.isDebugEnabled())
|
" node: " + nodeRef + "\n" +
|
||||||
{
|
" txn: " + txnId);
|
||||||
logger.debug(" --> Node not found (OK)");
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else
|
// we know that these are all deletions
|
||||||
|
ResultSet results = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
SearchParameters sp = new SearchParameters();
|
||||||
|
sp.addStore(storeRef);
|
||||||
|
// search for it in the index, sorting with youngest first, fetching only 1
|
||||||
|
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||||
|
sp.setQuery("ID:" + LuceneQueryParser.escape(nodeRef.toString()));
|
||||||
|
sp.setLimit(1);
|
||||||
|
|
||||||
|
results = searcher.query(sp);
|
||||||
|
|
||||||
|
if (results.length() == 0)
|
||||||
{
|
{
|
||||||
logger.debug(" --> Node found (Index out of date)");
|
// no results, as expected
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug(" --> Node not found (OK)");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug(" --> Node found (Index out of date)");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
finally
|
||||||
finally
|
{
|
||||||
{
|
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())
|
||||||
|
Reference in New Issue
Block a user