Skip to content

Commit

Permalink
Add logging of errors in _msearch and msearch template (elastic#101576)
Browse files Browse the repository at this point in the history
  • Loading branch information
quux00 authored Nov 9, 2023
1 parent aae4970 commit 04f26a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

package org.elasticsearch.script.mustache;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.MultiSearchRequest;
import org.elasticsearch.action.search.MultiSearchResponse;
Expand All @@ -31,6 +34,8 @@

public class TransportMultiSearchTemplateAction extends HandledTransportAction<MultiSearchTemplateRequest, MultiSearchTemplateResponse> {

private static final Logger logger = LogManager.getLogger(TransportMultiSearchTemplateAction.class);

private final ScriptService scriptService;
private final NamedXContentRegistry xContentRegistry;
private final NodeClient client;
Expand Down Expand Up @@ -76,6 +81,9 @@ protected void doExecute(Task task, MultiSearchTemplateRequest request, ActionLi
searchRequest = convert(searchTemplateRequest, searchTemplateResponse, scriptService, xContentRegistry, searchUsageHolder);
} catch (Exception e) {
items[i] = new MultiSearchTemplateResponse.Item(null, e);
if (ExceptionsHelper.status(e).getStatus() >= 500 && ExceptionsHelper.isNodeOrShardUnavailableTypeException(e) == false) {
logger.warn("MultiSearchTemplate convert failure", e);
}
continue;
}
items[i] = new MultiSearchTemplateResponse.Item(searchTemplateResponse, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

package org.elasticsearch.action.search;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
Expand All @@ -31,6 +34,7 @@

public class TransportMultiSearchAction extends HandledTransportAction<MultiSearchRequest, MultiSearchResponse> {

private static final Logger logger = LogManager.getLogger(TransportMultiSearchAction.class);
private final int allocatedProcessors;
private final ThreadPool threadPool;
private final ClusterService clusterService;
Expand Down Expand Up @@ -155,6 +159,9 @@ public void onResponse(final SearchResponse searchResponse) {

@Override
public void onFailure(final Exception e) {
if (ExceptionsHelper.status(e).getStatus() >= 500 && ExceptionsHelper.isNodeOrShardUnavailableTypeException(e) == false) {
logger.warn("TransportMultiSearchAction failure", e);
}
handleResponse(request.responseSlot, new MultiSearchResponse.Item(null, e));
}

Expand Down

0 comments on commit 04f26a0

Please sign in to comment.