From 7e5c2389989ae1c861ddb7cfcc8d63a94ed99baa Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 4 May 2015 21:39:17 +0200 Subject: [PATCH] Only mark translog committed in restore recovery --- .../java/org/elasticsearch/index/engine/InternalEngine.java | 2 -- .../index/snapshots/IndexShardSnapshotAndRestoreService.java | 1 + .../org/elasticsearch/index/IndexWithShadowReplicasTests.java | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 242974af13c..e03cb7b97f6 100644 --- a/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -145,8 +145,6 @@ public class InternalEngine extends Engine { if (skipInitialTranslogRecovery) { // make sure we point at the latest translog from now on.. commitIndexWriter(writer, translog.currentId()); - translog.markCommitted(translog.currentId()); - } else { recoverFromTranslog(engineConfig, committedTranslogId); } diff --git a/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java b/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java index 4ca9c488665..7c698457605 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java +++ b/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java @@ -126,6 +126,7 @@ public class IndexShardSnapshotAndRestoreService extends AbstractIndexShardCompo } indexShardRepository.restore(restoreSource.snapshotId(), shardId, snapshotShardId, recoveryState); indexShard.skipTranslogRecovery(); + indexShard.translog().markCommitted(indexShard.translog().currentId()); indexShard.finalizeRecovery(); indexShard.postRecovery("restore done"); restoreService.indexShardRestoreCompleted(restoreSource.snapshotId(), shardId); diff --git a/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasTests.java b/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasTests.java index b3a7b97ecfd..3a9750000e3 100644 --- a/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasTests.java +++ b/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.index; -import com.carrotsearch.randomizedtesting.annotations.Repeat; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;