Skip to content

LOAD DATA with flate compression hangs indefinitely — query stuck at planning/dispatch phase with no execution #25554

Closed

Description

@Ariznawlll

Summary

LOAD DATA with compression='flate' on a large file (40M rows x 100 columns) hangs indefinitely for 2h44m until workflow timeout. The query never reaches the CN execution layer — it gets stuck at the planning/dispatch phase.

Environment

  • Branch: main (commit b9efcce)
  • Cluster: TKE, 3 CNs + 1 DN
  • CN memory limit: 55 GiB
  • Job: LOAD DATA TEST
  • Namespace: mo-main-commit-b9efcce38-20260709

Reproduction

load data url s3option {
  'endpoint'='http://cos.ap-guangzhou.myqcloud.com',
  'bucket'='mo-load-guangzhou-1308875761',
  'filepath'='compressed_file/40000000_100_columns_load_data.flate',
  'compression'='flate'
} into table test.table_100_columns
fields terminated by ',' lines terminated by '\n' parallel 'true';

Timeline

04:22:56  LOAD DATA started
04:22:56 - 07:07:24  COMPLETELY SILENT (2h 44m)
  - No CN logs about load/flate/compress
  - No memory growth on any CN (stable 27-30 GiB)
  - No goroutine growth (stable ~3100 per CN)
  - No GC pauses (p75 < 1ms)
  - DN shows 0 data written to table_100_columns
07:07:24  Job cancelled by workflow timeout

Comparison with other loads on the same table

File Rows Compression Duration Status
10000_100_columns.csv 10K none 1.4s OK
100000_100_columns.csv 100K none 7.4s OK
1000000_100_columns.csv 1M none 35s OK
100000000_100_columns.csv 100M none 4.9 min OK
40000000_100_columns.csv 40M none 2.0 min OK
1000000_100_columns.csv.bz2 1M bz2 3.3 min OK
40000000_100_columns.flate 40M flate 2h44m (hung) HANG

Only flate compression causes the hang. Same data uncompressed or bz2-compressed loads fine.

Detailed Analysis

1. Memory — No growth during hang

CN tp-cn-stk5q: 33.1 GiB (04:20) -> 27.5 GiB (07:10)  [dropped, no load activity]
CN tp-cn-5hbr6: 33.9 GiB (04:20) -> 28.5 GiB (04:30-07:00) -> 47.1 GiB (07:10, cleanup spike)
CN tp-cn-hrxmr: 34.4 GiB (04:20) -> 29.4 GiB (04:40-07:00) -> 38.6 GiB (07:10)

Memory was completely flat during the 2h44m hang period. If flate decompression were running, memory would grow.

2. Goroutines — No load-related goroutines

Queried Pyroscope goroutine profile for the hang period. Found zero goroutines in:

  • flate decompression
  • CSV parsing
  • S3 file reading
  • LOAD DATA import
  • File decode/parse

Top goroutine stacks are all system background workers in normal select-wait state:

  • 64K: filterObjectWorker.Run (idle)
  • 33K: concurrentExecutor.Run (idle)
  • 10K: disttae.concurrentExecutor.Run (idle)
  • 9K: dragonboat ssWorker (idle)

3. DN — No data written

DN logs show MergeExecutorEvent-L0Gather for table_100_columns with l0count:0 and ago: 10m15s — confirming no data reached the storage layer.

4. Proxy — Connection issues

Both proxy pods showed close connection failed errors every 5 seconds starting from ~04:29, suggesting the client connection was left dangling.

Root Cause

The LOAD DATA query is stuck at the query planning/dispatch phase before it reaches any CN worker for execution. The most likely cause:

  1. Query planner needs to read the flate file header from S3 to determine schema/column mapping
  2. The flate reader initialization blocks indefinitely (no read timeout on S3 HTTP request, or flate stream reader hangs)
  3. No timeout protection on the planning phase — the query waits forever

This is NOT:

  • Memory pressure (memory is flat)
  • GC issue (GC is normal)
  • Goroutine leak (goroutines are flat)
  • Data processing issue (no data was ever read)

Suggested Fix

  1. Add read timeout to the S3 HTTP client used for flate file header reading
  2. Add timeout protection to the LOAD DATA planning phase
  3. Add logging at the planning phase start so hangs are diagnosable
  4. Consider whether flate compression should be supported for large files, or add a size limit/warning

Activity

  1. added
    kind/bug
    on Jul 9, 2026
  2. added theissue type on Jul 9, 2026
  3. added this to the MO-202607 milestone on Jul 9, 2026
  4. ck89119 commented on Jul 9, 2026

    @ck89119
    Contributor

    根因调查结论

    report 中的假设(planning 阶段读 flate 文件头导致 hang)不正确。 真正原因在执行阶段。

    日志证据

    在 tp-cn-stk5q 上,LOAD 开始(04:22:56.241 UTC)后 55ms 即出现致命错误:

    dispatch/dispatch.go:98  "internal error: SendToAnyLocalFunc should not send to remote"
    

    紧接着持续狂刷(整个 hang 期间不停重试):

    morpc/backend.go  "init remote connection failed"  remote:""  error:"dial tcp4: missing address"
    

    根因链

    1. 压缩文件(任意类型 flate/bz2/gzip 等)+ 足够大让 mcpu > 1 → 走 compileExternScanParallelWrite(串行读、并行写 dispatch)
    2. 该函数 source scope 硬编码了空地址:
      scope := c.constructScopeForExternal("", false)  // Addr = ""
    3. 而 target merge scope 带当前 CN 真实地址
    4. #25537(本次测试 commit b9efcce)新引入的 sameExecutionNode 替代了旧的 isSameCN:
      • 旧 isSameCN:空地址 Split("", ":") 长度≠2 → 打 warning 后 return true(容错为本地)
      • 新 sameExecutionNode:一空一非空 → return false(判为不同节点 → 生成 RemoteRegs 且 NodeAddr 为空)
    5. 后果:
      • dispatch Prepare 阶段读到 RemoteRegs + FuncId=SendToAnyLocalFunc → 报 dispatch.go:98 错误
      • runtime 向空地址建 morpc 连接 → dial tcp4: missing address 无限重试
    6. Pipeline 既不前进也不退出,内存/goroutine/GC 全程平稳(与观察一致),直到 workflow timeout

    为什么其他 load 不复现

    场景 mcpu 路径 结果
    bz2 1M(小) 1 mcpu==1 → 直接返回单 scope,不构造 dispatch 成功 ✅
    未压缩 40M >1 compileExternScanParallelReadWrite,另一条构造路径,source 地址正确 成功 ✅
    压缩大文件 flate/bz2/gzip >1 compileExternScanParallelWrite,source 地址为空 HANG ❌

    结论

    这与 flate 压缩类型无关,任何 mcpu > 1 的压缩文件 LOAD 都会被 #25537(refactor(schedule): introduce staged query placement)引入的回归击穿。

    修复方向:让 compileExternScanParallelWrite 中 source scope 的地址与 target merge scope 对齐。

  5. self-assigned this
    on Jul 9, 2026
  6. added
    ai-easy
    severity/s0
    on Jul 9, 2026
  7. added a commit that references this issue on Jul 10, 2026
    6891155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions