fix concurrency bug in index throttling

This commit is contained in:
mikemccand 2014-09-28 12:30:48 -04:00
parent 336ef4d468
commit 9e8c51b70d
1 changed files with 2 additions and 2 deletions

View File

@ -1735,7 +1735,7 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
} }
@Override @Override
public void beforeMerge(OnGoingMerge merge) { public synchronized void beforeMerge(OnGoingMerge merge) {
if (numMergesInFlight.incrementAndGet() > maxNumMerges) { if (numMergesInFlight.incrementAndGet() > maxNumMerges) {
if (isThrottling.getAndSet(true) == false) { if (isThrottling.getAndSet(true) == false) {
logger.info("now throttling indexing: numMergesInFlight={}, maxNumMerges={}", numMergesInFlight, maxNumMerges); logger.info("now throttling indexing: numMergesInFlight={}, maxNumMerges={}", numMergesInFlight, maxNumMerges);
@ -1745,7 +1745,7 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
} }
@Override @Override
public void afterMerge(OnGoingMerge merge) { public synchronized void afterMerge(OnGoingMerge merge) {
if (numMergesInFlight.decrementAndGet() < maxNumMerges) { if (numMergesInFlight.decrementAndGet() < maxNumMerges) {
if (isThrottling.getAndSet(false)) { if (isThrottling.getAndSet(false)) {
logger.info("stop throttling indexing: numMergesInFlight={}, maxNumMerges={}", numMergesInFlight, maxNumMerges); logger.info("stop throttling indexing: numMergesInFlight={}, maxNumMerges={}", numMergesInFlight, maxNumMerges);