[ENGINE] Add current translog ID to commit meta before closing

Today we simply close the IW when we have to open a new one if ie.
we change merge settings. Yet, the API is deprecated and under the hood
it commits the IW. For safety we should add the current translog ID and
use rollback instead to not wait for merges.
This commit is contained in:
Simon Willnauer 2014-10-27 14:46:06 +01:00
parent 006acfe8bf
commit 0a072f6fd0

View File

@ -838,10 +838,12 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
// disable refreshing, not dirty // disable refreshing, not dirty
dirty = false; dirty = false;
try { try {
// that's ok if the index writer failed and is in inconsistent state { // commit and close the current writer - we write the current tanslog ID just in case
// we will get an exception on a dirty operation, and will cause the shard final long translogId = translog.currentId();
// to be allocated to a different node indexWriter.setCommitData(MapBuilder.<String, String>newMapBuilder().put(Translog.TRANSLOG_ID_KEY, Long.toString(translogId)).map());
currentIndexWriter().close(false); indexWriter.commit();
indexWriter.rollback();
}
indexWriter = createWriter(); indexWriter = createWriter();
mergeScheduler.removeListener(this.throttle); mergeScheduler.removeListener(this.throttle);