What is the bug?
The ResourceStats schema in spec/schemas/_common.yaml of the opensearch-api-specification marks average, max, min, thread_info, and total as all required. However, the _tasks API on OpenSearch 1.3 only returns total in the resource_stats block when a task is in-flight.
Per the compatibility matrix, opensearch-java 3.x supports OpenSearch 1.x-3.x, so the spec should reflect what 1.x actually returns.
This causes the opensearch-java 3.8.0 client to throw:
org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'ResourceStats.average'
at org.opensearch.client.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:90)
at org.opensearch.client.opensearch._types.ResourceStats.<init>(ResourceStats.java:82)
at org.opensearch.client.opensearch._types.ResourceStats$Builder.build(ResourceStats.java:302)
at org.opensearch.client.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:92)
How can one reproduce the bug?
1. Index test documents (100k+):
POST /test-index/_bulk
{"index":{"_id":"1"}}
{"date":"2020-01-01T00:00:00Z","status":"OPEN"}
{"index":{"_id":"2"}}
{"date":"2020-01-01T00:00:00Z","status":"OPEN"}
... (repeat to 100k+ documents)
2. Submit async delete-by-query:
POST /test-index/_delete_by_query?wait_for_completion=false&conflicts=proceed
{
"query": {
"range": {
"date": {
"lt": "now-6M/d"
}
}
}
}
Response:
{
"task": "nodeId:1234567"
}
3. Poll the task while it's still running:
GET /_tasks/nodeId:1234567
In-flight response (before task completes):
{
"completed": false,
"task": {
"node": "nodeId",
"id": 1234567,
"type": "transport",
"action": "indices:data/write/delete/byquery",
"status": {
"total": 100000,
"updated": 0,
"created": 0,
"deleted": 11000,
"batches": 12,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0
},
"description": "delete-by-query [test-index]",
"start_time_in_millis": 1781528541973,
"running_time_in_nanos": 587603829,
"cancellable": true,
"cancelled": false,
"headers": {},
"resource_stats": {
"total": {
"cpu_time_in_nanos": 0,
"memory_in_bytes": 0
}
}
}
}
Note: resource_stats contains only total. The fields average, max, min, and thread_info are absent. The opensearch-java 3.8.0 client fails to deserialize this response because ResourceStats marks all five fields as required.
4. After task completes, resource_stats is no longer present in the response, which is why this only surfaces when polling in-flight tasks with large enough data volumes for the task to take seconds.
Environment
- opensearch-java client version: 3.8.0
- OpenSearch server: 1.3
- Java version: 17
What is the bug?
The
ResourceStatsschema inspec/schemas/_common.yamlof the opensearch-api-specification marksaverage,max,min,thread_info, andtotalas all required. However, the_tasksAPI on OpenSearch 1.3 only returnstotalin theresource_statsblock when a task is in-flight.Per the compatibility matrix, opensearch-java 3.x supports OpenSearch 1.x-3.x, so the spec should reflect what 1.x actually returns.
This causes the opensearch-java 3.8.0 client to throw:
How can one reproduce the bug?
1. Index test documents (100k+):
2. Submit async delete-by-query:
Response:
{ "task": "nodeId:1234567" }3. Poll the task while it's still running:
In-flight response (before task completes):
{ "completed": false, "task": { "node": "nodeId", "id": 1234567, "type": "transport", "action": "indices:data/write/delete/byquery", "status": { "total": 100000, "updated": 0, "created": 0, "deleted": 11000, "batches": 12, "version_conflicts": 0, "noops": 0, "retries": { "bulk": 0, "search": 0 }, "throttled_millis": 0, "requests_per_second": -1.0, "throttled_until_millis": 0 }, "description": "delete-by-query [test-index]", "start_time_in_millis": 1781528541973, "running_time_in_nanos": 587603829, "cancellable": true, "cancelled": false, "headers": {}, "resource_stats": { "total": { "cpu_time_in_nanos": 0, "memory_in_bytes": 0 } } } }Note:
resource_statscontains onlytotal. The fieldsaverage,max,min, andthread_infoare absent. The opensearch-java 3.8.0 client fails to deserialize this response becauseResourceStatsmarks all five fields as required.4. After task completes,
resource_statsis no longer present in the response, which is why this only surfaces when polling in-flight tasks with large enough data volumes for the task to take seconds.Environment