Skip to content

[BUG] PPL Inner Join crash OpenSearch with OOM #4430

Closed

Description

@penghuo

Query Information

PPL Command/Query:

POST {{baseUrl}}/_plugins/_ppl/
Content-Type: application/x-ndjson

{
    "query": "source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(code) | join type=inner left=SUCCESS right=FAILED on SUCCESS.remote = FAILED.ClientIP [ source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(log) | parse log '.+client: (?<ClientIP>.+?),.*'] | dedup ClientIP, agent"
}

Actual Result:

OpenSearch crashed with OOM

=== Standard error of node `node{:opensearch-sql-plugin:integTest-0}` ===
»   ↓ last 40 non error or warning messages from /Users/penghuo/oss/os-sql/plugin/build/testclusters/integTest-0/logs/opensearch.stderr.log ↓
» WARNING: Using incubator modules: jdk.incubator.vector
»  WARNING: Unknown module: org.apache.arrow.memory.core specified to --add-opens
»  fatal error in thread [opensearch[integTest-0][scheduler][T#1]], exiting
»  java.lang.OutOfMemoryError: Java heap space
»       at org.opensearch.common.util.concurrent.ThreadContext.preserveContext(ThreadContext.java:558)
»       at org.opensearch.threadpool.ThreadPool.schedule(ThreadPool.java:602)
»       at org.opensearch.threadpool.Scheduler$ReschedulingRunnable.onAfter(Scheduler.java:266)
»       at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.onAfter(ThreadContext.java:953)
»       at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:56)
»       at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
»       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
»       at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
»       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
»       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
»       at java.base/java.lang.Thread.runWith(Thread.java:1596)
»       at java.base/java.lang.Thread.run(Thread.java:1583)

Expected Result:

no crash

Dataset Information

Dataset/Schema Type

  • OpenTelemetry (OTEL)
  • Simple Schema for Observability (SS4O)
  • Open Cybersecurity Schema Framework (OCSF)
  • Custom (ngix)

Follow doc to prepare index and data.

Bug Description

Issue Summary:

Environment Information

OpenSearch Version: 3.3

Screenshots

n/a

Activity

  1. added
    bug
    PPL
    on Oct 2, 2025
  2. LantaoJin commented on Oct 14, 2025

    @LantaoJin
    Member

    @penghuo with the PR of restriction on join.subsearch_max merged. can you try the test again with main branch?

  3. self-assigned this
    on Oct 27, 2025
  4. moved this from Not Started to In review in PPL Trackeron Oct 27, 2025
  5. yuancu commented on Jan 20, 2026

    @yuancu
    Collaborator

    In the latest build, the query still fails.

    RCA

    • The left table, produced by source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(code), has 9510 rows, where every row has the same remote 10.0.1.151
    • The right table, produced by source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(log) | parse log '.+client: (?<ClientIP>.+?),.*', has 490 rows, where every row has the same ClientIP 10.0.1.151
    • After the inner join | join type=inner left=SUCCESS right=FAILED on SUCCESS.remote = FAILED.ClientIP, it produces 4,659,900 rows, because every row in the left table matches every row in the right table,.
    • The subsequent dedup, which is translated to the following physical plan, is a memory-intensive operation (it contains window functions):
       EnumerableCalc(expr#0..23=[{inputs}], expr#24=[1], expr#25=[<=($t23, $t24)], proj#0..23=[{exprs}], $condition=[$t25])
         EnumerableWindow(window#0=[window(partition {2, 22} rows between UNBOUNDED PRECEDING and CURRENT ROW aggs [ROW_NUMBER()])])
      

    This leads to the OOM. If the dedup command is removed, the query returns fairly quickly.

    I think this is a hardware limitation. Two ways I can come up with to solve it are:

    • further optimize dedup for cases where the max duplication is $$1$$ (can be simplified with SELECT DISTINCT)
    • create a circuit breaker mechanism to prevent the cluster from OOM, returning error for such cases
  6. LantaoJin commented on Jan 20, 2026

    @LantaoJin
    Member

    @yuancu thinks for confirming, let me close this since the OOM is not related to join. OOM caused by dedup operation in memory. For circuit breaker mechanism, we do have a health monitor, can you help to check why it doesn't work as expected in your testing.

  7. moved this from In review to Done in PPL Trackeron Jan 20, 2026
  8. LantaoJin commented on Jan 20, 2026

    @LantaoJin
    Member

    @yuancu can you try query

    source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(code) | join type=inner max=1 left=SUCCESS right=FAILED on SUCCESS.remote = FAILED.ClientIP [ source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(log) | parse log '.+client: (?.+?),.*'] | dedup ClientIP, agent"

    The max=1 is the default value in SPL, but we use max=0 as default.

  9. yuancu commented on Jan 20, 2026

    @yuancu
    Collaborator

    @LantaoJin when setting max=1, i.e.

    source=sso_logs-nginx-prod-2024.05.08
      | where ISPRESENT(code) 
      | join type=inner max=1 left=SUCCESS right=FAILED on SUCCESS.remote = FAILED.ClientIP 
        [ source=sso_logs-nginx-prod-2024.05.08 | where ISPRESENT(log) | parse log '.+client: (?<ClientIP>.+?),.*'] 
      | dedup ClientIP, agent
    

    the query instantly returns with one record (as the values on of condition key are the same across the two tables). Yet when using the default setting, it leads to cluster crash with OOM error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions