Repository navigation
Description
Query Information
PPL Command/Query:
source = opensearch_dashboards_sample_data_logs | stats values(response) by geo.dest
The failure is not specific to values(). Any stats/eventstats whose aggregation cannot be pushed down to OpenSearch triggers it. Confirmed triggers:
# non-pushdownable aggregation function
source = opensearch_dashboards_sample_data_logs | stats values(response) by geo.dest
source = opensearch_dashboards_sample_data_logs | stats list(response) by geo.dest
# window function (eventstats -> COUNT() OVER (...), no pushdown form)
source = opensearch_dashboards_sample_data_logs | eventstats count() by response
# group-by on a `text` field WITHOUT a .keyword subfield, or a `nested`/array field
source = <index> | stats count by <analyzed_text_field_without_keyword>
Expected Result:
The aggregation is computed and rows are returned. If an aggregation genuinely cannot be pushed down, it should still execute correctly (and ideally without silently scanning the entire index).
Actual Result:
java.sql.SQLException: exception while executing query: Error occurred while creating PIT
for internal plugin operation
With the diagnostic wrapping from #5631 applied, the previously-hidden root cause is visible:
... nested: OpenSearchRejectedExecutionException[Trying to create too many Point In Time
contexts. Must be less than or equal to: [N]. This limit can be set by changing the
[search.max_open_pit_context] setting.]
On the stock plugin (without #5631) the underlying cause is discarded and the caller only sees the opaque Error occurred while creating PIT for internal plugin operation.
Dataset Information
Dataset/Schema Type
- OpenTelemetry (OTEL)
- Simple Schema for Observability (SS4O)
- Open Cybersecurity Schema Framework (OCSF)
- Custom (public reproduction uses the Dashboards sample logs dataset)
Index Mapping (public reproduction)
Uses the built-in opensearch_dashboards_sample_data_logs index as-is. No custom mapping required — values()/eventstats refuse pushdown regardless of mapping.
For the field-mapping variant (the production trigger), a group-by field mapped as text with no keyword subfield is enough:
{
"settings": { "index.max_result_window": 10000 },
"mappings": {
"properties": {
"resource": { "properties": { "attributes": { "properties": { "k8s_label": { "properties": {
"applicationid": { "type": "text" }
}}}}}}
}
}
}source = <that index> | stats count by `resource.attributes.k8s_label.applicationid`
Bug Description
Issue Summary:
A stats/eventstats query whose aggregation cannot be pushed down to OpenSearch silently degrades into a full-index document scan on the coordinator, which forces internal Point-in-Time (PIT) creation and can fail the whole query. There are two distinct problems stacked here.
Root cause #1 — a refused aggregation silently becomes a full-index scan (the real defect)
When stats ... by X can be translated into a native OpenSearch composite aggregation, the request is sent with size: 0 and no PIT is involved. When it cannot be translated, CalciteLogicalIndexScan.pushDownAggregate(...) returns null and Calcite falls back to aggregating client-side over a raw document scan. That fallback scan carries requestedTotalSize = Integer.MAX_VALUE (2147483647).
In OpenSearchRequestBuilder.build(...):
sourceBuilder.size() == 0is false (size is MAX_VALUE), so it does not short-circuit;buildRequestWithPit(...)then evaluatesstartFrom + size > maxResultWindow→2147483647 > 10000is always true →createPit(...)is called.
Note the scan does not issue one size = MAX_VALUE request. buildRequestWithPit clamps the per-page size to maxResultWindow and paginates through the whole index via the PIT (OpenSearchRequestBuilder.java:130-140). The net effect is "stream every matching document to the coordinator, PIT-paginated at max_result_window per page, and aggregate in-memory in Calcite." On a small index this is invisible; on a large index it is pathological, and the PIT it requires is simply the first place a visible error surfaces (even if PIT creation succeeded, the query would be extremely slow/memory-heavy).
Refusal path, confirmed in source. For values()/list() the refusal is specific — these are recognized aggregations, not unknown names:
- Every PPL UDAF is stamped
SqlKind.OTHER_FUNCTION(core/.../calcite/utils/UserDefinedFunctionUtils.java:99);values/listare defined viacreateUserDefinedAggFunction(core/.../expression/function/PPLBuiltinOperators.java:514-522). AggregateAnalyzer#createRegularAggregation'sOTHER_FUNCTIONcase resolves the name back toBuiltinFunctionName.VALUES/LIST— the lookup succeeds (opensearch/.../request/AggregateAnalyzer.java:559-561).- Its inner
switchonly handlesTAKE,FIRST,LAST,PERCENTILE_APPROX,DISTINCT_COUNT_APPROX;VALUES/LISThit thedefault→throw new AggregateAnalyzerException("Unsupported push-down aggregator ...")(AggregateAnalyzer.java:597-599). analyze()'s outercatch (Throwable)re-wraps it as the checkedExpressionNotAnalyzableException(AggregateAnalyzer.java:323-325).pushDownAggregate'scatch (Exception)returnsnull(CalciteLogicalIndexScan.java:426-431);AggregateIndexScanRule.applyseesnull, skipscall.transformTo, and theLogicalAggregatestays a client-side operator over the plain scan (AggregateIndexScanRule.java:100-104).
Conditions that refuse aggregation pushdown (all confirmed in code):
- a non-pushdownable aggregation function such as
values()/list()— via the path above; - group-by field is
textwith no.keywordsubfield —OpenSearchTextType.toKeywordSubField(...)returnsnull, the term-source resolution throws, and the samecatch → nullatCalciteLogicalIndexScan#pushDownAggregatefires (a different throw than the aggregator switch above); - group-by field is
nested/ARRAY— a separate earlyreturn nullguard inpushDownAggregate(CalciteLogicalIndexScan.java:392-401, see [BUG] Cannot pushdown a nested root as group-by key #5006); - the operation is a window function (
eventstats), which has no aggregation-pushdown form.
By contrast, count/avg/sum/min/max have dedicated builder cases (AggregateAnalyzer.java:481-528), so analyze() returns non-null and OpenSearchRequestBuilder#pushDownAggregation sets sourceBuilder.size(0) (OpenSearchRequestBuilder.java:214), routing build() to the no-PIT path. (Nuance: min/max on non-numeric/non-temporal fields push down as a top_hits aggregation rather than a native min/max metric agg — still size:0, still no PIT.)
Root cause #2 — the PIT failure is reported with an opaque, cause-less message
When the forced createPit fails, OpenSearchNodeClient#createPit (and the legacy PointInTimeHandlerImpl) discard the underlying cause and throw a fixed string "Error occurred while creating PIT for internal plugin operation". They also only recognize a security denial when OpenSearchSecurityException is the direct cause, so a transport-wrapped denial on a multi-node cluster is flattened into the same opaque string. This makes a resource failure (PIT-context exhaustion), a timeout, and a permission denial all indistinguishable to the operator. Addressed by #5631 (surfaces the root cause and unwraps the full cause chain). #5631 is a diagnostics fix only and does not address root cause #1.
Verification
Re-verified on a live single-node cluster (OpenSearch 3.x, plugins.calcite.enabled: true, opensearch_dashboards_sample_data_logs, 14,074 docs) at the behavioral, plan (_explain), and source level.
The query is trivial — PIT capacity is the only barrier. Same query, only search.max_open_pit_context changed:
search.max_open_pit_context |
Result of stats values(response) by geo.dest |
|---|---|
0 (node saturated / at limit) |
❌ Error occurred while creating PIT ... |
300 (headroom) |
✅ 173 rows |
The successful run returns only 173 buckets — the result is tiny; it fails at =0 purely because the client-side fallback opens a PIT to read its input documents. Under peak production concurrency a node sits effectively at its limit, reproducing the =0 case.
A trailing | head N does not prevent the PIT. ... | stats values(response) by geo.dest | head 200 still fails: head bounds the aggregation output (173 buckets, under 200 → nothing to trim), but the PIT is allocated for the input document scan that runs before the limit applies.
_explain confirms the split at plan level:
| Query | AGGREGATION in PushDownContext |
requestedTotalSize |
client-side agg |
|---|---|---|---|
stats count() by geo.dest |
present (pushed down) | — | no |
stats values(response) by geo.dest |
absent | 2147483647 | EnumerableAggregate |
Behavior matrix at max_open_pit_context=0 (❌ = PIT created then rejected; ✅ = no PIT):
| Query | Outcome |
|---|---|
stats count() by geo.dest |
✅ 173 |
stats count() by geo.dest | head 200 |
✅ 173 |
stats avg(bytes) by geo.dest |
✅ 173 |
stats sum(bytes) by geo.dest |
✅ 173 |
stats values(response) by geo.dest |
❌ PIT |
stats values(response) by geo.dest | head 200 |
❌ PIT |
stats list(response) by geo.dest |
❌ PIT |
head 500 (Logs-tab shape) |
✅ 500 |
fields response | head 500 |
✅ 500 |
Steps to Reproduce:
- Enable the Calcite engine:
PUT _cluster/settings {"transient":{"plugins.calcite.enabled":true}} - (To force the PIT failure deterministically on an idle single node)
PUT _cluster/settings {"transient":{"search.max_open_pit_context":0}}. At production scale this exhaustion happens naturally under peak concurrency; the setting just makes it reproducible locally. - Load the
opensearch_dashboards_sample_data_logssample dataset. - Run
source = opensearch_dashboards_sample_data_logs | stats values(response) by geo.dest. - Observe the
Error occurred while creating PIT ...failure. - Contrast: a bounded document fetch such as
source = opensearch_dashboards_sample_data_logs | fields bytes | head 500succeeds (size < window ⇒ no PIT), and a pushdownablesource = ... | stats count by responsesucceeds (size: 0⇒ no PIT).
Impact:
- User-facing query failures on aggregation/statistics views for fields that don't push down (commonly deep OTel fields dynamically mapped as analyzed
textornested). - The failure is load- and mapping-dependent, so it presents as intermittent ("only at peak") and is hard to reproduce.
- Because even users with full permissions hit it, and because of root cause OpenSearch Migration for SQL/PPL #2, it is easily misdiagnosed as a permissions problem when the true cause is a full-scan-forced PIT hitting
search.max_open_pit_context(or a circuit breaker/timeout). - Silent degradation to a full-index scan is a latent performance/stability risk independent of the PIT error.
Environment Information
OpenSearch Version: reproduced on OpenSearch 3.x with the Calcite engine enabled (plugins.calcite.enabled: true).
Additional Details:
- Related diagnostics PR: Surface PIT-context exhaustion with an actionable error message #5631 (makes the underlying PIT failure visible; not a fix for root cause OpenSearch migration for SQL/PPL #1).
- Related nested/array pushdown limitation: [BUG] Cannot pushdown a nested root as group-by key #5006.
Suggested Direction
- Preferred (root cause OpenSearch migration for SQL/PPL #1): avoid silently degrading a refused aggregation into a
size = MAX_VALUEfull scan. Options: keep aggregating but bound/paginate sanely; fall back to a pushed-down form where possible (e.g. use a.keywordsubfield when present); or fail fast with an actionable message instead of an implicit full scan. - Mitigation (root cause OpenSearch Migration for SQL/PPL #2): ship Surface PIT-context exhaustion with an actionable error message #5631 so operators can see whether a PIT failure is exhaustion, timeout, or permission. Separately, verify PITs are always released on query cancellation/failure so abandoned UI queries don't leak PIT contexts and accelerate exhaustion.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
Use resolvable links in the review package