Skip to content

TPCH 1T OOM on 16 GiB CN: fix spill thresholds and cgroup memory detection #24327

Closed

Description

@jiangxinmeng1

What type of issue is this?

Bug / Performance

Description

Running TPCH 1T (scale factor 1000) on a 3-CN cluster with 16 GiB memory per CN causes OOM kills. The root causes are:

  1. Incorrect memory detection in containers: system.MemoryTotal() returns host memory (62G) instead of cgroup limit (16G) when the container uses tini (pid != 1), causing mpool.GlobalCap to be set to ~47G — far exceeding the actual container budget.

  2. HashBuild spill thresholds too loose: Per-operator spill threshold was derived from the inflated GlobalCap, allowing individual hash builds to accumulate too much data before spilling.

  3. GroupBy spill inefficiency: GroupBy spill threshold was too tight (causing excessive expensive serialize/deserialize cycles on Q17), and hash table rebuild on spill reload did not pre-size — leading to O(log N) resize overhead.

  4. GroupBy spill reload panic: PreAllocateGroups with hints > AggBatchSize created multi-chunk state arrays, but GroupGrow filled from the last chunk while getXY indexed from chunk 0, causing BatchMerge to panic with "index out of range [0] with length 0" on Q18/Q20.

Environment

  • 3 CN pods, 16 GiB memory each (cgroup v2)
  • cn_gomemlimit=4000 MiB, cn_memory_cache_size=2 GiB
  • TPCH scale factor 1000 (1T data)
  • Container init: tini (pid != 1)

Expected behavior

All 22 TPCH queries complete without OOM or panic.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions