Skip to content

Complex query causes high memory consumption ignoring limits #61238

Closed

Description

@amoskaliov

Describe what's wrong

Well, our analysts made up a query that causes high memory consumption which ends with OOM. The worst part is that Clickhouse is ignoring max_server_memory_usage parameter and consumes all available memory making our server freeze.

Does it reproduce on the most recent release?

Yes, reproducible on 24.2.1.2248

How to reproduce

I simplified the query as much as I could using only built-in tables.

WITH (SELECT number FROM system.numbers LIMIT 1) as w1,
(SELECT number FROM system.numbers LIMIT 1) as w2,
(SELECT number FROM system.numbers LIMIT 1) as w3,
(SELECT number FROM system.numbers LIMIT 1) as w4,
(SELECT number FROM system.numbers LIMIT 1) as w5,
(SELECT number FROM system.numbers LIMIT 1) as w6
SELECT number FROM (
    SELECT number FROM system.numbers LIMIT 10
    UNION ALL
    SELECT number FROM system.numbers LIMIT 10
)
WHERE number < 5

Expected behavior

Throw exception: MEMORY_LIMIT_EXCEEDED or AST_IS_TOO_BIG or complete the query successfully without exceeding memory limit.

Additional context

Log while executing the query above. I killed container with Ctrl+C.
crash.log

Activity

  1. added
    potential bug
    on Mar 12, 2024
  2. UnamedRus commented on Mar 12, 2024

    @UnamedRus
    Contributor

    Related #53752

  3. nikitamikhaylov commented on Apr 3, 2024

    @nikitamikhaylov
    Member

    It works with a new Analyzer on 24.3 and head. I will add this example as a test case here: #62185

  4. added
    memory
    and removed
    potential bug
    on Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    memory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions