From 77c2445f7d733b2e281abe9f3b9dc1868648a19e Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 14 Oct 2015 16:44:22 -0400 Subject: [PATCH] don't call IMC.forceCheck when going active; remove nocommit/sops --- .../ElasticsearchConcurrentMergeScheduler.java | 2 +- .../org/elasticsearch/index/shard/IndexShard.java | 13 +++---------- .../indices/memory/IndexingMemoryController.java | 7 ++----- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/engine/ElasticsearchConcurrentMergeScheduler.java b/core/src/main/java/org/elasticsearch/index/engine/ElasticsearchConcurrentMergeScheduler.java index 81466128c56..0566e80a37d 100644 --- a/core/src/main/java/org/elasticsearch/index/engine/ElasticsearchConcurrentMergeScheduler.java +++ b/core/src/main/java/org/elasticsearch/index/engine/ElasticsearchConcurrentMergeScheduler.java @@ -178,7 +178,7 @@ class ElasticsearchConcurrentMergeScheduler extends ConcurrentMergeScheduler { boolean isEnabled = getIORateLimitMBPerSec() != Double.POSITIVE_INFINITY; if (config.isAutoThrottle() && isEnabled == false) { enableAutoIOThrottle(); - } else if (config.isAutoThrottle() == false && isEnabled){ + } else if (config.isAutoThrottle() == false && isEnabled) { disableAutoIOThrottle(); } } 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 fee033feef3..d4d4330a68b 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -179,7 +179,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndexSett public static final String INDEX_TRANSLOG_FLUSH_THRESHOLD_OPS = "index.translog.flush_threshold_ops"; public static final String INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE = "index.translog.flush_threshold_size"; public static final String INDEX_TRANSLOG_DISABLE_FLUSH = "index.translog.disable_flush"; - + public static final String INDEX_REFRESH_INTERVAL = "index.refresh_interval"; private final ShardPath path; @@ -898,12 +898,6 @@ public class IndexShard extends AbstractIndexShardComponent implements IndexSett /** Records timestamp of the last write operation, possibly switching {@code active} to true if we were inactive. */ private void markLastWrite(Engine.Operation op) { lastWriteNS = op.startTime(); - if (active.getAndSet(true) == false) { - // We are currently inactive, but a new write operation just showed up, so we now notify IMC - // to wake up and fix our indexing buffer. We could do this async instead, but cost should - // be low, and it's rare this happens. - indexingMemoryController.forceCheck(); - } } private void ensureWriteAllowed(Engine.Operation op) throws IllegalIndexShardStateException { @@ -963,8 +957,6 @@ public class IndexShard extends AbstractIndexShardComponent implements IndexSett } } - public static final String INDEX_REFRESH_INTERVAL = "index.refresh_interval"; - public void addFailedEngineListener(Engine.FailedEngineListener failedEngineListener) { this.failedEngineListener.delegates.add(failedEngineListener); } @@ -1177,7 +1169,6 @@ public class IndexShard extends AbstractIndexShardComponent implements IndexSett * changes. */ public void refreshAsync(final String reason) { - // nocommit this really is async??? engineConfig.getThreadPool().executor(ThreadPool.Names.REFRESH).execute(new Runnable() { @Override public void run() { @@ -1202,6 +1193,8 @@ public class IndexShard extends AbstractIndexShardComponent implements IndexSett @Override public void run() { try { + // TODO: now that we use refresh to clear the indexing buffer, we should check here if we did that "recently" and + // reschedule if so... if (getEngine().refreshNeeded()) { refresh("schedule"); } diff --git a/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java b/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java index 6073aa54626..5519fdd9fd7 100644 --- a/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java +++ b/core/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryController.java @@ -54,7 +54,7 @@ public class IndexingMemoryController extends AbstractLifecycleComponent indexingBuffer.bytes()) { // OK we are using too much; make a queue and ask largest shard(s) to refresh: logger.debug("now refreshing some shards: total indexing bytes used [{}] vs index_buffer_size [{}]", new ByteSizeValue(totalBytesUsed), indexingBuffer); - PriorityQueue queue = new PriorityQueue<>(); for (ShardId shardId : availableShards()) { long shardBytesUsed = getIndexBufferRAMBytesUsed(shardId);