fix full flush when no changes happen in the index, so the updated trans id is not written

This commit is contained in:
Shay Banon 2011-09-15 14:56:37 +03:00
parent 28f56262bc
commit 25c6e8512d
1 changed files with 13 additions and 1 deletions

View File

@ -833,7 +833,19 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
long translogId = translogIdGenerator.incrementAndGet(); long translogId = translogIdGenerator.incrementAndGet();
translog.newTransientTranslog(translogId); translog.newTransientTranslog(translogId);
indexWriter.commit(MapBuilder.<String, String>newMapBuilder().put(Translog.TRANSLOG_ID_KEY, Long.toString(translogId)).map()); indexWriter.commit(MapBuilder.<String, String>newMapBuilder().put(Translog.TRANSLOG_ID_KEY, Long.toString(translogId)).map());
translog.makeTransientCurrent(); if (flush.force()) {
// if we force, we might not have committed, we need to check that its the same id
Map<String, String> commitUserData = IndexReader.getCommitUserData(store.directory());
long committedTranslogId = Long.parseLong(commitUserData.get(Translog.TRANSLOG_ID_KEY));
if (committedTranslogId != translogId) {
// we did not commit anything, revert to the old translog
translog.revertTransient();
} else {
translog.makeTransientCurrent();
}
} else {
translog.makeTransientCurrent();
}
} catch (Exception e) { } catch (Exception e) {
translog.revertTransient(); translog.revertTransient();
throw new FlushFailedEngineException(shardId, e); throw new FlushFailedEngineException(shardId, e);