diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryBufferController.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryBufferController.java index 8729042d38e..322945d7265 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryBufferController.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/memory/IndexingMemoryBufferController.java @@ -40,6 +40,7 @@ public class IndexingMemoryBufferController extends AbstractComponent { private final ByteSizeValue indexingBuffer; private final ByteSizeValue minShardIndexBufferSize; + private final ByteSizeValue maxShardIndexBufferSize; private final IndicesService indicesService; @@ -69,8 +70,9 @@ public class IndexingMemoryBufferController extends AbstractComponent { this.indexingBuffer = indexingBuffer; this.minShardIndexBufferSize = componentSettings.getAsBytesSize("min_shard_index_buffer_size", new ByteSizeValue(4, ByteSizeUnit.MB)); + this.maxShardIndexBufferSize = componentSettings.getAsBytesSize("max_shard_index_buffer_size", new ByteSizeValue(512, ByteSizeUnit.MB)); - logger.debug("using index_buffer_size [{}], with min_shard_index_buffer_size [{}]", this.indexingBuffer, this.minShardIndexBufferSize); + logger.debug("using index_buffer_size [{}], with min_shard_index_buffer_size [{}], max_shard_index_buffer_size [{}]", this.indexingBuffer, this.minShardIndexBufferSize, this.maxShardIndexBufferSize); indicesService.indicesLifecycle().addListener(listener); } @@ -97,6 +99,9 @@ public class IndexingMemoryBufferController extends AbstractComponent { if (shardIndexingBufferSize.bytes() < minShardIndexBufferSize.bytes()) { shardIndexingBufferSize = minShardIndexBufferSize; } + if (shardIndexingBufferSize.bytes() > maxShardIndexBufferSize.bytes()) { + shardIndexingBufferSize = maxShardIndexBufferSize; + } logger.debug("recalculating shard indexing buffer (reason={}), total is [{}] with [{}] shards, each shard set to [{}]", reason, indexingBuffer, shardsCount, shardIndexingBufferSize); for (IndexService indexService : indicesService) { for (IndexShard indexShard : indexService) {