From ea055d2ac94fa9408cee6e0c381113928a4db323 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 31 Mar 2016 15:54:21 +0200 Subject: [PATCH] add a comment why and when we can ignore skipTranslogRecovery in IndexShard --- .../java/org/elasticsearch/index/shard/IndexShard.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 38bf43e4c2c..b916f5e8e7f 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -882,6 +882,13 @@ public class IndexShard extends AbstractIndexShardComponent { } recoveryState.setStage(RecoveryState.Stage.TRANSLOG); final EngineConfig.OpenMode openMode; + /* by default we recover and index and replay the translog but if the index + * doesn't exist we create everything from the scratch. Yet, if the index + * doesn't exist we don't need to worry about the skipTranslogRecovery since + * there is no translog on a non-existing index. + * The skipTranslogRecovery invariant is used if we do remote recovery since + * there the translog isn't local but on the remote host, hence we can skip it. + */ if (indexExists == false) { openMode = EngineConfig.OpenMode.CREATE_INDEX_AND_TRANSLOG; } else if (skipTranslogRecovery) {