nfsantos commented on code in PR #2343:
URL: https://github.com/apache/jackrabbit-oak/pull/2343#discussion_r2161809232


##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticBulkProcessorHandler.java:
##########
@@ -481,41 +449,35 @@ public void beforeBulk(long executionId, BulkRequest 
request, List<OperationCont
 
         @Override
         public void afterBulk(long executionId, BulkRequest request, 
List<OperationContext> contexts, BulkResponse response) {
+            // Bullk request has been processed successfully. Some operations 
may have failed, but the request itself was successful.
             try {
                 LOG.debug("Bulk with id {} processed in {} ms", executionId, 
response.took());
                 if (LOG.isTraceEnabled()) {
                     LOG.trace(response.toString());
                 }
 
-                HashMap<String, FailedDocSetTracker> failedDocSetMap = new 
HashMap<>();
                 for (int i = 0; i < contexts.size(); i++) {
                     IndexInfo indexInfo = contexts.get(i).indexInfo;
                     BulkResponseItem item = response.items().get(i);
                     if (item.error() == null) {
                         indexInfo.indexModified = true;
                     } else {
-                        FailedDocSetTracker failedDocSet = 
failedDocSetMap.computeIfAbsent(
-                                indexInfo.indexName,
-                                // TODO: this must be thread safe because 
there may be several callback threads.
-                                //   However, this is not performance critical 
so we can use coarse grained locking
-                                k -> new 
FailedDocSetTracker(indexInfo.definitionBuilder));
-
-                        if (failOnError && 
indexInfo.suppressedErrorCauses.size() < MAX_SUPPRESSED_ERROR_CAUSES) {
+                        if (failOnIndexingError && 
indexInfo.suppressedErrorCauses.size() < MAX_SUPPRESSED_ERROR_CAUSES) {
                             indexInfo.suppressedErrorCauses.add(item.error());
                         }
-                        String documentId = contexts.get(i).documentId;
-                        failedDocSet.addFailedDocument(documentId);
-
-                        // Log entry to be used to parse logs to get the 
failed doc id/path if needed
-                        LOG.error("ElasticIndex Update Doc Failure: Error 
while adding/updating doc with id: [{}]", documentId);
-                        LOG.error("Failure Details: BulkItem ID: {}, Index: 
{}, Failure Cause: {}",
-                                item.id(), item.index(), item.error());
+                        String type = item.error().type() != null ? 
item.error().type() : "type-unknown";
+                        String reason = item.error().reason() != null ? 
item.error().reason() : "reason-unknown";
+                        if (reason.length() > 20) {
+                            reason = reason.substring(0, 20) + "...";
+                        }
+                        String logSilenceKey = indexInfo.indexName + ":" + 
type + ":" + reason;
+                        if (!LOG_SILENCER.silence(logSilenceKey)) {
+                            // Log entry to be used to parse logs to get the 
failed doc id/path if needed
+                            LOG.warn("Failure Details: BulkItem ID: {}, Index: 
{}, Failure Cause: {} - {}",

Review Comment:
   I'm not sure. This message is printed when a document fails to index, so it 
is an error caused by the user providing a wrong/invalid document or index 
rule. This can happen quite often and pollute the logs with ERROR level 
messages which are not that critical. As it is not a failure on our side, I 
think WARN level is more appropriate. But I don't have a strong opinion here, 
so I'm willing to change it to ERROR if you think it's better.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to