From 9148382be0822a4301aea95564b128c3351df7f4 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 14 Sep 2015 05:12:06 -0400 Subject: [PATCH] even if engineUnsafe() is null we still must update the EngineConfig --- .../elasticsearch/index/shard/IndexShard.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 c07ec52e386..1b0bbe92bb3 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -115,9 +115,6 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -/** - * - */ public class IndexShard extends AbstractIndexShardComponent { private final ThreadPool threadPool; @@ -985,17 +982,18 @@ public class IndexShard extends AbstractIndexShardComponent { } public void updateBufferSize(ByteSizeValue shardIndexingBufferSize, ByteSizeValue shardTranslogBufferSize) { - Engine engine = engineUnsafe(); - if (engine == null) { - logger.debug("updateBufferSize: engine is closed; skipping"); - return; - } final EngineConfig config = engineConfig; final ByteSizeValue preValue = config.getIndexingBufferSize(); config.setIndexingBufferSize(shardIndexingBufferSize); + Engine engine = engineUnsafe(); + if (engine == null) { + logger.debug("updateBufferSize: engine is closed; skipping"); + return; + } + // update engine if it is already started. if (preValue.bytes() != shardIndexingBufferSize.bytes()) { if (shardIndexingBufferSize == EngineConfig.INACTIVE_SHARD_INDEXING_BUFFER) { @@ -1278,6 +1276,8 @@ public class IndexShard extends AbstractIndexShardComponent { return engine; } + /** NOTE: returns null if engine is not yet started (e.g. recovery phase 1, copying over index files, is still running), or if engine is + * closed. */ protected Engine engineUnsafe() { return this.currentEngineReference.get(); }