[BUG] stats max and stats min return 500 when a field is keyword or ip and boolean or a number in another
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Start by reproducing the supplied logs_a/logs_b mappings and stats max(f) and stats min(f) queries through the /_plugins/_ppl endpoint; compare with pushdown disabled. Then read the top_hits pushdown for non-numeric max and min introduced in #4281 and trace how the merged field type affects the aggregation. Done means mixed mappings no longer produce an uninformative HTTP 500: the query returns a valid maximum or minimum, or a 400 that identifies the conflicting types.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Query Information
PPL Command/Query:
source=logs_* | stats max(f)
f is keyword in logs_a and boolean in logs_b, which is what a rollover mapping change leaves behind.
Expected Result: the maximum over both indices, or a 400 naming the conflicting types.
Actual Result: HTTP 500, and details does not name the cause. stats min(f) fails the same way.
{
"error": {
"context": {
"stage": "executing",
"stage_description": "Running the query"
},
"reason": "java.sql.SQLException: exception while executing query: Failed to fetch data from the index: the background task failed or interrupted.\n Inner error: Failed to execute phase [fetch], ",
"details": "java.sql.SQLException: exception while executing query: Failed to fetch data from the index: the background task failed or interrupted.\n Inner error: Failed to execute phase [fetch], ",
"location": ["while running the query"],
"code": "UNKNOWN",
"type": "RuntimeException"
},
"status": 500
}
The cause shows up in the node log and in caused_by.reason on a raw _search that sends the DSL from _explain to logs_*. Adding ?error_trace=true to that search gives the stack below.
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class org.apache.lucene.util.BytesRef
at org.apache.lucene.search.comparators.TermOrdValComparator.compareValues(TermOrdValComparator.java:53)
...
at org.apache.lucene.search.TopDocs.merge(TopDocs.java:261)
at org.opensearch.search.aggregations.metrics.InternalTopHits.reduce(InternalTopHits.java:150)
at org.opensearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:188)
at org.opensearch.search.aggregations.InternalAggregations.topLevelReduce(InternalAggregations.java:135)
at org.opensearch.action.search.SearchPhaseController.reduceAggs(SearchPhaseController.java:561)
Dataset Information
Dataset/Schema Type
- OpenTelemetry (OTEL)
- Simple Schema for Observability (SS4O)
- Open Cybersecurity Schema Framework (OCSF)
- Custom (details below)
Index Mapping
PUT logs_a { "mappings": { "properties": { "host": { "type": "keyword" }, "f": { "type": "keyword" } } } }
PUT logs_b { "mappings": { "properties": { "host": { "type": "keyword" }, "f": { "type": "boolean" } } } }
Sample Data
POST logs_a/_doc/1?refresh=true { "host": "a", "f": "300" }
POST logs_b/_doc/1?refresh=true { "host": "b", "f": true }
Bug Description
Issue Summary:
PPL pushes max and min on a field that is not a number or date type, such as string, ip or boolean, as a top_hits of size 1 sorted on f. Over a wildcard, PPL picks between the native aggregation and top_hits from the merged type of f, while each shard sorts f by its own mapping. A keyword or ip shard returns a BytesRef sort value, and a boolean shard returns an Integer. InternalTopHits.reduce merges them with one Lucene comparator, which throws a ClassCastException.
Each index alone returns 200. The merged type is whichever index the mapping merge reads last, see #5752. It changes with the index names, so every pair below ran under 10 different name prefixes on fresh indices. In the last column both indices hold a document with host set to s, and the query is where host = 's' | stats max(f) by host.
f in one index |
f in the other |
merged type | stats max(f) |
stats min(f) |
stats max(f) by host, one host in both indices |
|---|---|---|---|---|---|
keyword |
boolean |
boolean |
500 | 500 | 500 |
keyword |
boolean |
string |
500 | 500 | 500 |
ip |
boolean |
boolean |
500 | 500 | 500 |
ip |
boolean |
ip |
500 | 500 | 500 |
keyword |
long |
string |
500 | 500 | 500 |
keyword |
long |
bigint |
200, "300" dropped |
200, "300" dropped |
200, "300" dropped |
ip |
long |
ip |
500 | 500 | 500 |
boolean |
long |
boolean |
500 | 500 | 500 |
keyword |
ip |
string or ip |
200, wrong for some values | 200, wrong for some values | 200, wrong for some values |
integer |
long |
int or bigint |
200 | 200 | 200 |
The values were "300" for keyword, 5 for the integer types, true for boolean and 10.0.0.1 for ip.
Every 500 in the table is this bug. The keyword and boolean pair and the ip and boolean pair fail under both merged types. The other failing pairs fail only when the merged type is string, ip or boolean, because a numeric or date merged type pushes a native max or min with no sort to merge. keyword against ip never fails, since both sides sort as BytesRef. The 200 cells marked wrong or dropped are other defects, and the dropped value is #5687.
With plugins.calcite.pushdown.enabled set to false, the same query returns 200, since no top_hits reaches OpenSearch. With Calcite off, the v2 engine rejects both functions on logs_* under boolean with a 400.
#5825 is the same TopDocs.merge failure reached through a pushed sort, with the top-level SearchPhaseController.sortDocs in place of InternalTopHits.reduce. The sort here sits inside an aggregation, so it does not go through the sort pushdown that #5825 covers.
Steps to Reproduce:
curl -s -XPUT "localhost:9200/logs_a" -H 'Content-Type: application/json' \
-d '{"mappings":{"properties":{"host":{"type":"keyword"},"f":{"type":"keyword"}}}}'
curl -s -XPUT "localhost:9200/logs_b" -H 'Content-Type: application/json' \
-d '{"mappings":{"properties":{"host":{"type":"keyword"},"f":{"type":"boolean"}}}}'
curl -s -XPOST "localhost:9200/logs_a/_doc/1?refresh=true" -H 'Content-Type: application/json' -d '{"host":"a","f":"300"}'
curl -s -XPOST "localhost:9200/logs_b/_doc/1?refresh=true" -H 'Content-Type: application/json' -d '{"host":"b","f":true}'
# 1. Returns HTTP 500, whichever type the merge picks for f
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_* | stats max(f)"}' -w '\nHTTP %{http_code}\n'
# 2. stats min returns the same 500
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_* | stats min(f)"}' -w '\nHTTP %{http_code}\n'
# 3. Each index alone returns 200
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_a | stats max(f)"}' -w '\nHTTP %{http_code}\n'
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_b | stats max(f)"}' -w '\nHTTP %{http_code}\n'
# 4. A top_hits sorted on f, the shape PPL pushes, sent as a raw search with no plugin,
# also returns 500, with the ClassCastException in caused_by
curl -s -XPOST "localhost:9200/logs_*/_search?error_trace=true" -H 'Content-Type: application/json' \
-d '{"size":0,"aggs":{"m":{"top_hits":{"size":1,"sort":[{"f":{"order":"desc"}}]}}}}' -w '\nHTTP %{http_code}\n'
# 5. With pushdown off, queries 1 and 2 return 200
curl -s -XPUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' \
-d '{"transient":{"plugins.calcite.pushdown.enabled":false}}'
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_* | stats max(f)"}' -w '\nHTTP %{http_code}\n'
curl -s -XPOST "localhost:9200/_plugins/_ppl" -H 'Content-Type: application/json' \
-d '{"query":"source=logs_* | stats min(f)"}' -w '\nHTTP %{http_code}\n'
# Restore the default
curl -s -XPUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' \
-d '{"transient":{"plugins.calcite.pushdown.enabled":null}}'
Impact:
After a rollover changes the mapping of a field, stats max and stats min on that field over the data stream or its wildcard return 500, and the response does not say which field or which types conflict.
Environment Information
OpenSearch Version: main at 803ed31c8, 3.10.0-SNAPSHOT, one node, one shard per index. plugins.calcite.enabled is true, plugins.calcite.pushdown.enabled is true and plugins.calcite.fallback.allowed is false.
Additional Details:
- #4281 introduced the
top_hitspushdown formaxandminon non-numeric fields.
- Lenguaje dominante
- Java
- Estrellas
- 176
- Forks
- 237
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 34
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de opensearch-project/sql
-
bug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opensearch-project/sql#5990 ·
Los mantenedores suelen responder en 1 día
-
bug untriaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
opensearch-project/sql#5983 ·
Los mantenedores suelen responder en 1 día
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Posiblemente ocupada @nagendramohan la tomó hace 107 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
opensearch-project/sql#5684 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
[DOC] Calcite settings documentation missing examplesPosiblemente ocupada @AzazelSensei la tomó hace 64 días. Abiertodocumentation PPL
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
opensearch-project/sql#4806 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
calcite enhancement Meta performance PPL untriaged
Dificultad 5/5 Más de una semana Aptitud para principiantes 8/100
opensearch-project/sql#5991 ·
Los mantenedores suelen responder en 1 día
Todos los issues de opensearch-project/sql
Issues similares
-
NeoForge 安装任务的子任务描述有误Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
PCL-Community/PCL-CE#3907 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 2 días
-
area/dependencies area/dependencies/quarkus backport/26.6 backport/26.8 kind/cve severity/critical source/scan-dependencies status/triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
docker-to-squash.py: check_dependencies should find mksquashfs on PATHPosiblemente ocupada @linzch3 la tomó hoy. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
chore
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
lugassawan/swe-workbench#841 ·