From: Simon Brandhof Date: Fri, 20 Mar 2015 10:52:12 +0000 (+0100) Subject: Do not retry to index failed requests in BulkIndexer X-Git-Tag: 5.1-RC2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4010dadc61187e390d044408873cdce1af4829f6;p=sonarqube.git Do not retry to index failed requests in BulkIndexer --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java index 218da47bd84..a43ba7a4fcd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/es/BulkIndexer.java @@ -20,7 +20,6 @@ package org.sonar.server.es; import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; @@ -42,7 +41,6 @@ import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.server.util.ProgressLogger; -import java.util.List; import java.util.Map; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; @@ -103,8 +101,6 @@ public class BulkIndexer implements Startable { return this; } - - @Override public void start() { Preconditions.checkState(bulkRequest == null, ALREADY_STARTED_MESSAGE); @@ -212,35 +208,13 @@ public class BulkIndexer implements Startable { semaphore.release(); counter.addAndGet(response.getItems().length); - List retries = Lists.newArrayList(); for (BulkItemResponse item : response.getItems()) { if (item.isFailed()) { - ActionRequest retry = req.request().requests().get(item.getItemId()); - retries.add(retry); - } - } - - if (!retries.isEmpty()) { - LOGGER.warn(String.format("%d index requests failed. Trying again.", retries.size())); - BulkRequestBuilder retryBulk = client.prepareBulk(); - for (ActionRequest retry : retries) { - retryBulk.request().add(retry); - } - BulkResponse retryBulkResponse = retryBulk.get(); - if (retryBulkResponse.hasFailures()) { - LOGGER.error("New attempt to index documents failed"); - for (int index = 0; index < retryBulkResponse.getItems().length; index++) { - BulkItemResponse item = retryBulkResponse.getItems()[index]; - if (item.isFailed()) { - StringBuilder sb = new StringBuilder(); - String msg = sb.append("\n[").append(index) - .append("]: index [").append(item.getIndex()).append("], type [").append(item.getType()).append("], id [").append(item.getId()) - .append("], message [").append(item.getFailureMessage()).append("]").toString(); - LOGGER.error(msg); - } - } - } else { - LOGGER.info("New index attempt succeeded"); + StringBuilder sb = new StringBuilder(); + String msg = sb + .append("index [").append(item.getIndex()).append("], type [").append(item.getType()).append("], id [").append(item.getId()) + .append("], message [").append(item.getFailureMessage()).append("]").toString(); + LOGGER.error(msg); } } }