Skip to content

Commit

Permalink
Handle any exception thrown while generating source for an IngestDocu…
Browse files Browse the repository at this point in the history
…ment (#91981)
  • Loading branch information
joegallo committed Nov 29, 2022
1 parent cafcd4f commit e3f2ba7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/91981.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 91981
summary: Handle any exception thrown while generating source for an `IngestDocument`
area: Ingest Node
type: bug
issues: []
19 changes: 15 additions & 4 deletions server/src/main/java/org/elasticsearch/ingest/IngestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,8 @@ private void innerExecute(
boolean ensureNoSelfReferences = ingestDocument.doNoSelfReferencesCheck();
indexRequest.source(ingestDocument.getSource(), indexRequest.getContentType(), ensureNoSelfReferences);
} catch (IllegalArgumentException ex) {
// An IllegalArgumentException can be thrown when an ingest
// processor creates a source map that is self-referencing.
// In that case, we catch and wrap the exception so we can
// include which pipeline failed.
// An IllegalArgumentException can be thrown when an ingest processor creates a source map that is self-referencing.
// In that case, we catch and wrap the exception, so we can include which pipeline failed.
totalMetrics.ingestFailed();
handler.accept(
new IllegalArgumentException(
Expand All @@ -959,6 +957,19 @@ private void innerExecute(
)
);
return;
} catch (Exception ex) {
// If anything goes wrong here, we want to know, and cannot proceed with normal execution. For example,
// *rarely*, a ConcurrentModificationException could be thrown if a pipeline leaks a reference to a shared mutable
// collection, and another indexing thread modifies the shared reference while we're trying to ensure it has
// no self references.
totalMetrics.ingestFailed();
handler.accept(
new RuntimeException(
"Failed to generate the source document for ingest pipeline [" + pipeline.getId() + "]",
ex
)
);
return;
}
Map<String, String> map;
if ((map = metadata.getDynamicTemplates()) != null) {
Expand Down

0 comments on commit e3f2ba7

Please sign in to comment.