Skip to content

Commit 4026ff2

Browse files
authored
Handle any exception thrown while generating source for an IngestDocument (#91981)
1 parent 58237b2 commit 4026ff2

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

docs/changelog/91981.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 91981
2+
summary: Handle any exception thrown while generating source for an `IngestDocument`
3+
area: Ingest Node
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/ingest/IngestService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,17 +945,27 @@ private void innerExecute(
945945
boolean ensureNoSelfReferences = ingestDocument.doNoSelfReferencesCheck();
946946
indexRequest.source(ingestDocument.getSource(), indexRequest.getContentType(), ensureNoSelfReferences);
947947
} catch (IllegalArgumentException ex) {
948-
// An IllegalArgumentException can be thrown when an ingest
949-
// processor creates a source map that is self-referencing.
950-
// In that case, we catch and wrap the exception so we can
951-
// include which pipeline failed.
948+
// An IllegalArgumentException can be thrown when an ingest processor creates a source map that is self-referencing.
949+
// In that case, we catch and wrap the exception, so we can include which pipeline failed.
952950
handler.accept(
953951
new IllegalArgumentException(
954952
"Failed to generate the source document for ingest pipeline [" + pipeline.getId() + "]",
955953
ex
956954
)
957955
);
958956
return;
957+
} catch (Exception ex) {
958+
// If anything goes wrong here, we want to know, and cannot proceed with normal execution. For example,
959+
// *rarely*, a ConcurrentModificationException could be thrown if a pipeline leaks a reference to a shared mutable
960+
// collection, and another indexing thread modifies the shared reference while we're trying to ensure it has
961+
// no self references.
962+
handler.accept(
963+
new RuntimeException(
964+
"Failed to generate the source document for ingest pipeline [" + pipeline.getId() + "]",
965+
ex
966+
)
967+
);
968+
return;
959969
}
960970
Map<String, String> map;
961971
if ((map = metadata.getDynamicTemplates()) != null) {

0 commit comments

Comments
 (0)