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 { 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())) { if (IndexReader.indexExists(store.directory())) {
Map<String, String> commitUserData = IndexReader.getCommitUserData(store.directory()); Map<String, String> commitUserData = IndexReader.getCommitUserData(store.directory());
if (commitUserData.containsKey(Translog.TRANSLOG_ID_KEY)) { if (commitUserData.containsKey(Translog.TRANSLOG_ID_KEY)) {
@ -802,6 +804,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
indexWriter.close(false); indexWriter.close(false);
indexWriter = createWriter(); 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()) { if (flushNeeded || flush.force()) {
flushNeeded = false; flushNeeded = false;
long translogId = translogIdGenerator.incrementAndGet(); long translogId = translogIdGenerator.incrementAndGet();
@ -812,6 +816,8 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
AcquirableResource<ReaderSearcherHolder> current = nrtResource; AcquirableResource<ReaderSearcherHolder> current = nrtResource;
nrtResource = buildNrtResource(indexWriter); nrtResource = buildNrtResource(indexWriter);
current.markForClose(); current.markForClose();
refreshVersioningTable(threadPool.estimatedTimeInMillis());
} catch (Exception e) { } catch (Exception e) {
throw new FlushFailedEngineException(shardId, e); throw new FlushFailedEngineException(shardId, e);
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
@ -850,6 +856,13 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
} else { } else {
makeTransientCurrent = true; 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) { } catch (Exception e) {
translog.revertTransient(); translog.revertTransient();
throw new FlushFailedEngineException(shardId, e); throw new FlushFailedEngineException(shardId, e);
@ -863,13 +876,6 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
rwl.readLock().unlock(); 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 { try {
SegmentInfos infos = new SegmentInfos(); SegmentInfos infos = new SegmentInfos();
infos.read(store.directory()); infos.read(store.directory());