Skip to content

Commit

Permalink
only add other failures if anything left
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrik Muhs committed Jan 22, 2020
1 parent d2b17bf commit bfdaea8
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ protected void doNextBulk(BulkRequest request, ActionListener<BulkResponse> next
deduplicatedFailures.values()
);
if (irrecoverableException == null) {
String failureMessage = getBulkIndexDetailedFailureMessage(deduplicatedFailures);
logger.debug("[{}] Bulk index experienced [{}] failures. Significant falures: {}", getJobId(), failureMessage);
String failureMessage = getBulkIndexDetailedFailureMessage(" Significant falures: ", deduplicatedFailures);
logger.debug("[{}] Bulk index experienced [{}] failures.{}", getJobId(), failureMessage);

Exception firstException = deduplicatedFailures.values().iterator().next().getFailure().getCause();
nextPhase.onFailure(
Expand All @@ -193,11 +193,11 @@ protected void doNextBulk(BulkRequest request, ActionListener<BulkResponse> next
);
} else {
deduplicatedFailures.remove(irrecoverableException.getClass().getSimpleName());
String failureMessage = getBulkIndexDetailedFailureMessage(deduplicatedFailures);
String failureMessage = getBulkIndexDetailedFailureMessage(" Other failures: ", deduplicatedFailures);
irrecoverableException = decorateBulkIndexException(irrecoverableException);

logger.debug(
"[{}] Bulk index experienced [{}] failures and at least 1 irrecoverable [{}]. Other failures: {}",
"[{}] Bulk index experienced [{}] failures and at least 1 irrecoverable [{}].{}",
getJobId(),
failureCount,
ExceptionRootCauseFinder.getDetailedMessage(irrecoverableException),
Expand Down Expand Up @@ -356,8 +356,12 @@ SeqNoPrimaryTermAndIndex getSeqNoPrimaryTermAndIndex() {
return seqNoPrimaryTermAndIndex.get();
}

private static String getBulkIndexDetailedFailureMessage(Map<String, BulkItemResponse> failures) {
StringBuilder failureMessageBuilder = new StringBuilder();
private static String getBulkIndexDetailedFailureMessage(String prefix, Map<String, BulkItemResponse> failures) {
if (failures.isEmpty()) {
return "";
}

StringBuilder failureMessageBuilder = new StringBuilder(prefix);
for (Entry<String, BulkItemResponse> failure : failures.entrySet()) {
failureMessageBuilder.append("\n[")
.append(failure.getKey())
Expand Down

0 comments on commit bfdaea8

Please sign in to comment.