From 9e8c51b70d44c124bd3008cb4bb7c52fcb502f77 Mon Sep 17 00:00:00 2001 From: mikemccand Date: Sun, 28 Sep 2014 12:30:48 -0400 Subject: [PATCH] fix concurrency bug in index throttling --- .../elasticsearch/index/engine/internal/InternalEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java b/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java index df38b6d68ff..381d9544a16 100644 --- a/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java @@ -1735,7 +1735,7 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin } @Override - public void beforeMerge(OnGoingMerge merge) { + public synchronized void beforeMerge(OnGoingMerge merge) { if (numMergesInFlight.incrementAndGet() > maxNumMerges) { if (isThrottling.getAndSet(true) == false) { logger.info("now throttling indexing: numMergesInFlight={}, maxNumMerges={}", numMergesInFlight, maxNumMerges); @@ -1745,7 +1745,7 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin } @Override - public void afterMerge(OnGoingMerge merge) { + public synchronized void afterMerge(OnGoingMerge merge) { if (numMergesInFlight.decrementAndGet() < maxNumMerges) { if (isThrottling.getAndSet(false)) { logger.info("stop throttling indexing: numMergesInFlight={}, maxNumMerges={}", numMergesInFlight, maxNumMerges);