-
Notifications
You must be signed in to change notification settings - Fork 178
Description
What is the bug?
When executing aggregation queries with plugins.query.size_limit set higher than max_result_window (default 10,000), the query planner incorrectly triggers a PIT/scroll request. This results in unpredictable results for aggregation queries.
Root Cause: The size limit check in the query planner doesn't distinguish between aggregation and non-aggregation queries, contrary to the pagination design doc (https://github.com/opensearch-project/sql/blob/main/docs/dev/Pagination-v2.md#scope).
Code Reference: #1666
if (startFrom + size >= maxResultWindow) {
sourceBuilder.size(maxResultWindow - startFrom);
return new OpenSearchScrollRequest(
indexName, cursorKeepAlive, sourceBuilder, exprValueFactory, includes);
Impact: Unpredictable results for aggregation queries when plugins.query.size_limit exceeds max_result_window.
How can one reproduce the bug?
Set plugins.query.size_limit to 20,000:
{
"persistent": {
"plugins.query.size_limit": "20000"
}
}
Execute an aggregation query:
source=fluentd.services | where attrs.SERVICE_NAME='ratelimit' | stats count() as cnt
What is the expected behavior?
- PIT/Scroll request should not be triggered for aggregation queries
- Accurate number of datarows with the correct count should be returned
Do you have any screenshots?
Scroll query returns infinite loop of nulls

PIT query returns infinite loop of counts

Do you have any additional context?
- Scroll is by default in 2.17
- PIT is by default in 2.19
- Scroll has been removed in 3.x [v3.0.0] Deprecate scroll API usage #3346