Merged V2.9 to HEAD

9845: Merged V2.2 to V2.9
      9733: Merged V2.1 to V2.2
         9281: Improvements to index AUTO recovery
         9316: Fixed ETWOONE-193: Transactional caches not being cleaned up after rollback (2.1.4 regression)
         9317: Fixed ETWOONE-194: Faster void handling during index tracking
         9365: Improved performance for finding which snapshots have been indexed
         9413: Support to retrieve read/write state of the transaction and ensure Lucene commits are handled last
         9414: ACT-3245: Updating node properties and aspects don't bump the alf_node.version value
         9415: Code cleanup: Removed unnecessary empty methods
         9416: Fixed creation of multiple thread pools
         9417: Full index recovery absorbs indexing exceptions by default
         9418: Added AUTO index recovery option to sample in line with Wiki docs
         9419: ETWOONE-194: Index tracking is too slow
         9420: Fixed ETWOONE-201: Better logging and configurability for RetryingTransactionHelper
         9421: Fixed ETWOONE-202: SPlit person cleanup doesn't break read-only transactions
         9422: Follow up on CHK-3317: Removed use of JDK 1.6 NavigableMap interface
         9423: Fixed unit test after CHK-3317
         9424: More test fixes after CHK-3317
         9425: Ensure that index tracking tests don't run too long.
         9426: Made concurrent reindexing optional.  It is on by default.
         9509: ACT-3539: Mid-transaction locking on Lucene resources
         9547: Multithreaded index tracking startup: Handle previously lagging single-threaded rebuilds


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10592 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-08-30 03:11:18 +00:00
parent 75646b4234
commit 0ac7884d1b
31 changed files with 1934 additions and 536 deletions

View File

@@ -27,6 +27,7 @@ package org.alfresco.repo.node.index;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.alfresco.i18n.I18NUtil;
@@ -94,6 +95,7 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
private boolean lockServer;
private IndexTransactionTracker indexTracker;
private boolean stopOnError;
private int maxTransactionsPerLuceneCommit;
/**
* <ul>
@@ -105,6 +107,7 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
public FullIndexRecoveryComponent()
{
recoveryMode = RecoveryMode.VALIDATE;
maxTransactionsPerLuceneCommit = 100;
}
/**
@@ -118,6 +121,15 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
this.recoveryMode = RecoveryMode.valueOf(recoveryMode);
}
/**
* Set the number of transactions to process per Lucene write.
* Larger values generate less contention on the Lucene IndexInfo files.
*/
public void setMaxTransactionsPerLuceneCommit(int maxTransactionsPerLuceneCommit)
{
this.maxTransactionsPerLuceneCommit = maxTransactionsPerLuceneCommit;
}
/**
* Set this on to put the server into READ-ONLY mode for the duration of the index recovery.
* The default is <tt>true</tt>, i.e. the server will be locked against further updates.
@@ -178,10 +190,10 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
// Check that the first and last meaningful transactions are indexed
List<Transaction> startTxns = nodeDaoService.getTxnsByCommitTimeAscending(
Long.MIN_VALUE, Long.MAX_VALUE, 10, null);
Long.MIN_VALUE, Long.MAX_VALUE, 10, null, false);
boolean startAllPresent = areTxnsInIndex(startTxns);
List<Transaction> endTxns = nodeDaoService.getTxnsByCommitTimeDescending(
Long.MIN_VALUE, Long.MAX_VALUE, 10, null);
Long.MIN_VALUE, Long.MAX_VALUE, 10, null, false);
boolean endAllPresent = areTxnsInIndex(endTxns);
// check the level of cover required
@@ -275,12 +287,16 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
fromTimeInclusive,
toTimeExclusive,
MAX_TRANSACTIONS_PER_ITERATION,
lastTxnIds);
lastTxnIds,
false);
lastTxnIds = new ArrayList<Long>(nextTxns.size());
// reindex each transaction
for (Transaction txn : nextTxns)
List<Long> txnIdBuffer = new ArrayList<Long>(maxTransactionsPerLuceneCommit);
Iterator<Transaction> txnIterator = nextTxns.iterator();
while (txnIterator.hasNext())
{
Transaction txn = txnIterator.next();
Long txnId = txn.getId();
// Keep it to ensure we exclude it from the next iteration
lastTxnIds.add(txnId);
@@ -298,14 +314,22 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
}
else
{
try
// Add the transaction ID to the buffer
txnIdBuffer.add(txnId);
// Reindex if the buffer is full or if there are no more transactions
if (!txnIterator.hasNext() || txnIdBuffer.size() >= maxTransactionsPerLuceneCommit)
{
reindexTransaction(txnId);
}
catch (Throwable e)
{
String msgError = I18NUtil.getMessage(MSG_RECOVERY_ERROR, txnId, e.getMessage());
logger.info(msgError, e);
try
{
reindexTransactionAsynchronously(txnIdBuffer);
}
catch (Throwable e)
{
String msgError = I18NUtil.getMessage(MSG_RECOVERY_ERROR, txnId, e.getMessage());
logger.info(msgError, e);
}
// Clear the buffer
txnIdBuffer = new ArrayList<Long>(maxTransactionsPerLuceneCommit);
}
}
// Although we use the same time as this transaction for the next iteration, we also
@@ -324,6 +348,9 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
}
}
// Wait for the asynchronous process to catch up
waitForAsynchronousReindexing();
// have we finished?
if (nextTxns.size() == 0)
{
@@ -337,8 +364,8 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
}
/**
* Perform a full reindexing of the given transaction in the context of a completely
* new transaction.
* Perform full reindexing of the given transaction. A read-only transaction is created
* <b>if one doesn't already exist</b>.
*
* @param txnId the transaction identifier
*/
@@ -384,7 +411,7 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, false);
// done
}
}