Skip to content

Duplicate field in bulk request document line causes request to hang indefinitely #139707

@carsonip

Description

@carsonip

Elasticsearch Version

9.2.0

Installed Plugins

No response

Java Version

bundled

OS Version

Ubuntu 24.04

Problem Description

When sending a bulk request that contains a duplicate field in the document line, the request hangs. This is confirmed by the curl command below, as well as a packet dump showing no response being sent back to the curl.

This appears to be a regression in v9.2.0 and affects main. A quick git bisect from apm-server seems to show that this bug shows up after changing ES docker image (commit) from docker.elastic.co/elasticsearch/elasticsearch:9.1.0-f894ad4a-SNAPSHOT to docker.elastic.co/elasticsearch/elasticsearch:9.2.0-edc3c310-SNAPSHOT, which corresponds to a list of suspicious commits.

Discovered by open-telemetry/opentelemetry-collector-contrib#39304

Steps to Reproduce

curl -v -X POST -u admin:changeme -H "Content-Type: application/x-ndjson" -d '{"create":{"_index":"traces-generic.otel-default"}}
{"@timestamp":"1765904122817.96953","data_stream":{"type":"traces","dataset":"generic.otel","namespace":"default"},"trace_id":"8a57b7f4b53da724af6d8c70e760d5ac","span_id":"94a4de22c1817d7e","name":"process_payment","kind":"Server","duration":0,"attributes":{"http.request.method":"POST","http.response.status_code":200,"foo":"bar","foo":"baz","db.system":"postgresql"},"links":[],"status":{"code":"Ok"},"resource":{"attributes":{"service.name":"payment-service","deployment.environment":"staging"}},"scope":{"name":"manual-test-script"}}
' "http://localhost:9200/_bulk"

Logs (if relevant)

curl output

9.2 docker.elastic.co/elasticsearch/elasticsearch:9.2.0-edc3c310-SNAPSHOT:

* Host localhost:9200 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9200...
* Connected to localhost (::1) port 9200
* Server auth using Basic with user 'admin'
> POST /_bulk HTTP/1.1
> Host: localhost:9200
> Authorization: Basic YWRtaW46Y2hhbmdlbWU=
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/x-ndjson
> Content-Length: 590
> 
* Operation timed out after 3002 milliseconds with 0 bytes received
* Closing connection
curl: (28) Operation timed out after 3002 milliseconds with 0 bytes received

9.1 docker.elastic.co/elasticsearch/elasticsearch:9.1.0-f894ad4a-SNAPSHOT:

* Host localhost:9200 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9200...
* Connected to localhost (::1) port 9200
* Server auth using Basic with user 'admin'
> POST /_bulk HTTP/1.1
> Host: localhost:9200
> Authorization: Basic YWRtaW46Y2hhbmdlbWU=
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/x-ndjson
> Content-Length: 590
> 
< HTTP/1.1 200 OK
< X-elastic-product: Elasticsearch
< content-type: application/json
< Transfer-Encoding: chunked
< 
{"errors":true,"took":0,"items":[{"create":{"_index":".ds-traces-generic.otel-default-2025.12.17-000001","_id":"AZstcJajWuS5g6uuqoKU","status":400,"failure_store":"not_enabled","error":{"type":"document_parsing_exception","reason":"[1:326] failed to parse: [1:337] Duplicate field 'foo'\n at [Source: (byte[])\"{\"@timestamp\":\"1765904122817.96953\",\"data_stream\":{\"type\":\"traces\",\"dataset\":\"generic.otel\",\"namespace\":\"default\"},\"trace_id\":\"8a57b7f4b53da724af6d8c70e760d5ac\",\"span_id\":\"94a4de22c1817d7e\",\"name\":\"process_payment\",\"kind\":\"Server\",\"duration\":0,\"attributes\":{\"http.request.method\":\"POST\",\"http.response.status_code\":200,\"foo\":\"bar\",\"foo\":\"baz\",\"db.system\":\"postgresql\"},\"links\":[],\"status\":{\"code\":\"Ok\"},\"resource\":{\"attributes\":{\"service.name\":\"payment-service\",\"deployment.environment\":\"staging\"}},\"\"[truncated 37 bytes]; line: 1, column: 337]","caused_by":{"type":"x_content_parse_exception","reason":"[1:337] Duplicate field 'foo'\n at [Source: (byte[])\"{\"@timestamp\":\"1765904122817.96953\",\"data_stream\":{\"type\":\"traces\",\"dataset\":\"generic.otel\",\"namespace\":\"default\"},\"trace_id\":\"8a57b7f4b53da724af6d8c70e760d5ac\",\"span_id\":\"94a4de22c1817d7e\",\"name\":\"process_payment\",\"kind\":\"Server\",\"duration\":0,\"attributes\":{\"http.request.method\":\"POST\",\"http.response.status_code\":200,\"foo\":\"bar\",\"foo\":\"baz\",\"db.system\":\"postgresql\"},\"links\":[],\"status\":{\"code\":\"Ok\"},\"resource\":{\"attributes\":{\"service.name\":\"payment-service\",\"deployment.environment\":\"staging\"}},\"\"[truncated 37 bytes]; line: 1, column: 337]","caused_by":{"type":"json_parse_exception","reason":"Duplicate field 'foo'\n at [Source: (byte[])\"{\"@timestamp\":\"1765904122817.96953\",\"data_stream\":{\"type\":\"traces\",\"dataset\":\"generic.otel\",\"namespace\":\"default\"},\"trace_id\":\"8a57b7f4b53da724af6d8c70e760d5ac\",\"span_id\":\"94a4de22c1817d7e\",\"name\":\"process_payment\",\"kind\":\"Server\",\"duration\":* Connection #0 to host localhost left intact
0,\"attributes\":{\"http.request.method\":\"POST\",\"http.response.status_code\":200,\"foo\":\"bar\",\"foo\":\"baz\",\"db.system\":\"postgresql\"},\"links\":[],\"status\":{\"code\":\"Ok\"},\"resource\":{\"attributes\":{\"service.name\":\"payment-service\",\"deployment.environment\":\"staging\"}},\"\"[truncated 37 bytes]; line: 1, column: 337]"}}}}}]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions