move refreshing version table to be done right after the commit within the respective lock, for full flush (rarely used) its needed...

This commit is contained in:
Shay Banon 2011-09-18 16:11:17 +03:00
parent b66a3b7c59
commit 52ca63deb9
1 changed files with 13 additions and 7 deletions

View File

@ -248,6 +248,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
}
try {
// commit on a just opened writer will commit even if there are no changes done to it
// we rely on that for the commit data translog id key
if (IndexReader.indexExists(store.directory())) {
Map<String, String> commitUserData = IndexReader.getCommitUserData(store.directory());
if (commitUserData.containsKey(Translog.TRANSLOG_ID_KEY)) {
@ -802,6 +804,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
indexWriter.close(false);
indexWriter = createWriter();
// commit on a just opened writer will commit even if there are no changes done to it
// we rely on that for the commit data translog id key
if (flushNeeded || flush.force()) {
flushNeeded = false;
long translogId = translogIdGenerator.incrementAndGet();
@ -812,6 +816,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
AcquirableResource<ReaderSearcherHolder> current = nrtResource;
nrtResource = buildNrtResource(indexWriter);
current.markForClose();
refreshVersioningTable(threadPool.estimatedTimeInMillis());
} catch (Exception e) {
throw new FlushFailedEngineException(shardId, e);
} catch (OutOfMemoryError e) {
@ -850,6 +856,13 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
} else {
makeTransientCurrent = true;
}
if (makeTransientCurrent) {
refreshVersioningTable(threadPool.estimatedTimeInMillis());
// we need to move transient to current only after we refresh
// so items added to current will still be around for realtime get
// when tans overrides it
translog.makeTransientCurrent();
}
} catch (Exception e) {
translog.revertTransient();
throw new FlushFailedEngineException(shardId, e);
@ -863,13 +876,6 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
rwl.readLock().unlock();
}
}
refreshVersioningTable(threadPool.estimatedTimeInMillis());
// we need to move transient to current only after we refresh
// so items added to current will still be around for realtime get
// when tans overrides it
if (makeTransientCurrent) {
translog.makeTransientCurrent();
}
try {
SegmentInfos infos = new SegmentInfos();
infos.read(store.directory());