[BUG] stats max and stats min return 500 when a field is keyword or ip and boolean or a number in another
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 176
- Fork
- 237
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 34
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của opensearch-project/sql
-
bug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensearch-project/sql#5990 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
opensearch-project/sql#5983 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Có thể đã có người làm @nagendramohan đã nhận 107 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
opensearch-project/sql#5684 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[DOC] Calcite settings documentation missing examplesCó thể đã có người làm @AzazelSensei đã nhận 64 ngày trước. Đang mởdocumentation PPL
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
opensearch-project/sql#4806 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
calcite enhancement Meta performance PPL untriaged
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
opensearch-project/sql#5991 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của opensearch-project/sql
Issue tương tự
-
NeoForge 安装任务的子任务描述有误Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
PCL-Community/PCL-CE#3907 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/dependencies area/dependencies/quarkus backport/26.6 backport/26.8 kind/cve severity/critical source/scan-dependencies status/triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
docker-to-squash.py: check_dependencies should find mksquashfs on PATHCó thể đã có người làm @linzch3 đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
chore
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
lugassawan/swe-workbench#841 ·