opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.81k stars 1.83k forks source link

[BUG] Compressed bulk index request failures #16020

Closed thomas-long-f3 closed 1 month ago

thomas-long-f3 commented 1 month ago

Describe the bug

When upgrading from 2.16.0 > 2.17.0, all compressed bulk index requests fail.

Related component

Indexing

To Reproduce

Testing using the OpenSearch docker images. Single node mode, with security disabled.

  1. Generate a simple request:
echo '{ "index": { "_index": "test" } }
{ "hello": "world" }
' > bulk.json
  1. Perform a bulk request uncompressed:
curl http://localhost:9200/_bulk -H 'Content-Type: application/json' --data-binary @bulk.json

Successful response:

{"took":7,"errors":false,"items":[{"index":{"_index":"test","_id":"4pV3D5IBj6h56HIDqJfa","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1,"status":201}}]}
  1. Now compress the same file:
gzip bulk.json
  1. Send a compressed request:
curl http://localhost:9200/_bulk -H 'Content-Type: application/json' -H 'Content-Encoding: gzip' --data-binary @bulk.json.gz

Request fails:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"}],"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"},"status":400}

Note the file does contain a newline at the end, and works as expected on previous OS versions.

Expected behavior

A compressed request would be successful, like the uncompressed request.

Additional Details

Plugins Please list all plugins currently enabled.

Screenshots If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

Additional context Add any other context about the problem here.

bharath-techie commented 1 month ago

Looks like a breaking change, we need to reproduce this and try to fix this.

@thomas-long-f3 Are you interested in writing a failing test for this ?

reta commented 1 month ago

@thomas-long-f3 I am not able to reproduce the issue:

$ docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "DISABLE_SECURITY_PLUGIN=true" opensearchproject/opensearch:2.17.0
$ curl http://localhost:9200/_bulk -H 'Content-Type: application/json' -H 'Content-Encoding: gzip' --data-binary @bulk.json.gz

{"took":168,"errors":false,"items":[{"index":{"_index":"test","_id":"ctJkSJIBkHuKu8Vtt9yQ","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0}

Are you running it on Windows?

thomas-long-f3 commented 1 month ago

This is strange, I can no longer replicate this either. I thought I replicated this on a clean container, but I can only assume there was crossover with the stream testing I was performing on 2.17.

Closing, apologies for the false alarm!

reta commented 1 month ago

This is strange, I can no longer replicate this either. I thought I replicated this on a clean container, but I can only assume there was crossover with the stream testing I was performing on 2.17.

That could be it, the stream testing could make it behave like that , I will double check , thanks @thomas-long-f3