Skip to content

[Bug] Hive 2000-partition external scan + JOIN causes cluster-wide CN communication cascade failure (all CNs i/o timeout) #25980

Closed

Description

@Ariznawlll

Issue

In the nightly big-data regression, the Hive Partition test (29_external_hive_partition_agg_join.sql) fails with 4 consecutive 1800s query timeouts. CN server logs reveal a cluster-wide communication cascade failure: all 3 CN pods become simultaneously unresponsive to both client connections and internal CN-to-CN RPCs.

This is not the 30s dispatch registration timeout described in #25816 — that diagnosis was based on code analysis without CN server logs. The actual root cause is resource exhaustion from Hive external scan across 2000 parquet partitions.

Environment

Field Value
CI Run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29764908174/job/88444199451
Branch main
MO commit 0102f7b85bcb8d960d7cc16a14b71682a58e7910
Namespace mo-big-data-commit-0102f7b-suite-1y
Cluster TKE, 3 CNs + 1 DN + 3 Log + 2 Proxy
CN memory limit (standard big-data config)
Error window 2026-07-20 19:51–21:54 UTC

Failure Timeline

Client-side (runner log)

Time (UTC) SQL Duration Result
19:52:04 4 simple aggregations on fact_hive_2000 300ms–1.2s ✅
19:52:06 EXISTS subquery (fact + dim JOIN) 106s ✅ (slow but passed)
19:52:06 → 20:23:53 fact JOIN dim (the primary failure) 1800s ❌ timeout
20:23:53 → 20:53:53 fact self-JOIN (cascade) 1800s ❌ timeout
20:53:53 → 21:23:53 UNION ALL partition count (cascade) 1800s ❌ timeout
21:23:53 → 21:53:53 GROUP BY + ORDER BY + LIMIT (cascade) 1800s ❌ timeout

The primary failure SQL:

SELECT d.part_name, count(*) as rowcount
FROM external_hive_partition_2000_large.fact_hive_2000 f
JOIN external_hive_partition_2000_large.dim_part_2000 d ON f.part_id = d.part_id
WHERE d.part_id in (1, 7, 2000)
GROUP BY d.part_name ORDER BY d.part_name

Server-side (CN Loki logs)

All 3 CN pods became simultaneously unresponsive:

CN Pod IP First i/o timeout Memory Peak
tp-cn-trrnj 10.143.132.177 19:51:04 (before JOIN started!) 26.9 GiB
tp-cn-v89m9 10.143.132.176 19:51:54 17.1 GiB
tp-cn-sj7tp 10.143.132.175 19:52:21 16.3 GiB

Key observations from CN logs:

  1. i/o timeouts started BEFORE the JOIN query — CN trrnj showed timeouts from 19:51:04, while the JOIN query was submitted at 19:52:06. The EXISTS subquery (106s) was already stressing the cluster.

  2. All inter-CN communication failed simultaneously:

    • trrnj → sj7tp:6002 (cn-backend): use of closed network connection
    • trrnj → v89m9:6002: use of closed network connection
    • sj7tp → trrnj:6001: i/o timeout
    • v89m9 → sj7tp:6001: i/o timeout
    • Both proxy pods also failed to reach any CN on port 6001
  3. CN sj7tp table statistics collector completely stuck:

    WARN mo.table.stats.task "waited err another 30s" total=103 left=103
    

    Repeated every 30 seconds — 103 statistics tasks all failing.

  4. Empty messageBoard (19:58:53 on sj7tp):

    WARN "waiting message timeout, waiting for tag [1], messageBoard length: 0"
    

    Dispatch messages from other CNs never arrived.

  5. No dispatch process not registered within 30s errors anywhere in any CN log during the entire window.

  6. S3 slow events on Hive partition files:

    slow event: S3FS.Read hive_partition/types_2000_large/part_id=1870/data.parquet
    
  7. Memory: CN trrnj spiked to 26.9 GiB (from ~19 GiB baseline). Other CNs at 15-17 GiB. Not at limit but the spike correlates with the failure.

Root Cause

The Hive external scan across 2000 parquet partition files (path: hive_partition/types_2000_large/part_id=*/data.parquet) consumes so many goroutines, S3 connections, and CPU cycles that the CN cannot service any other work — including internal CN-to-CN RPC (port 6002), client connections (port 6001), and health checks.

When the fact/dim JOIN triggers a cross-CN shuffle, all 3 CNs try to scan partitions and shuffle data simultaneously. The combined load overwhelms all CNs at once, creating a cascade where no CN can respond to any other CN, causing the query to hang indefinitely until the client-side 1800s timeout.

The 3 subsequent timeouts are cascading effects: func_timeout returns control to the runner without proving the server-side query was cancelled, and the runner reuses the same connection/cursor on a still-overloaded cluster.

Why This Is Not #25816

Aspect #25816 hypothesis This issue (CN log evidence)
Core error dispatch process not registered within 30s Not present in any CN log
Failure trigger Receiver registration slower than 30s watchdog Hive 2000-partition scan exhausts CN resources
Timing After query dispatch Before the failing query even starts
Scope Specific remote dispatch path All CN-to-CN and client-to-CN communication
Evidence basis Code analysis without CN logs Actual CN Loki logs from the failing run

The original #25816 diagnosis explicitly noted: "The latest runner log does not expose the inner 30-second dispatch error... CN logs and a query profile are still required for that run." — the CN logs were never checked until now.

Suggested Investigation

  1. Hive external scan concurrency: The 2000-partition scan likely opens 2000 S3 reads concurrently. Add partition-level concurrency limits or batching.
  2. CN resource isolation: Hive external scan goroutines should not starve internal RPC handlers. Consider separate goroutine pools or priority scheduling for cn-backend (port 6002) traffic.
  3. Query-level timeout: Add a server-side query timeout (e.g., 300s for big-data queries) so that hung queries are cancelled server-side instead of relying solely on client-side timeout.
  4. Client cleanup: After func_timeout, the test runner should cancel the server-side query and create a fresh connection before executing the next statement, to prevent cascade timeouts.

Affected Test

  • Test file: cases/big_data_test/04_QUERIES/29_external_hive_partition_agg_join.sql
  • Intermittent: yes — the same test passes on some runs when the cluster is less loaded

Activity

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

    @Ariznawlll
    CollaboratorAuthor

    Correction: Relationship with #25816

    After checking the CN logs from the July 15 run (29428464735, the run documented in #25816 comment), I found that both errors co-exist in that run:

    1. remote receiver not ready within 30s, remote CN may have failed — appeared on CN 6z9sk at 17:51:42 UTC (the error described in [Bug] 30s remote dispatch watchdog can falsely fail slow receiver registration #25816)
    2. Full cluster i/o timeout cascade — same pattern as this issue (July 20 run)

    The July 20 run (0102f7b) does NOT show the 30s error because that commit already includes #25820 (the lifecycle-driven fix). The 30s watchdog no longer fires, but the underlying CN resource exhaustion from Hive 2000-partition scans is still present — it just manifests as indefinite hang instead of the explicit 30s error.

    Correct relationship:

    Hive 2000-partition external scan exhausts CN resources (root cause, this issue)
      → All CNs become unresponsive (i/o timeout cascade)
      → Before #25820: 30s watchdog fires "remote receiver not ready" (#25816 symptom)
      → After #25820: no 30s error, but query hangs indefinitely until client timeout
    

    #25816's diagnosis was not wrong — the 30s timeout IS a real symptom. But it is a cascading effect of the CN resource exhaustion, not an independent issue. The #25820 fix correctly removed the false-positive 30s error, but did not fix the underlying Hive scan resource problem, which is what this issue tracks.

  5. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    由原issue跟踪

  6. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    最小复现脚本

    不需要重新准备数据,直接用现有的 Hive 表 external_hive_partition_2000_large.fact_hive_2000。

    在 TKE 集群的 runner 上运行:

    # 用法: bash reproduce_hive_cascade.sh <proxy_ip> [port] [iterations]
    # 例:   bash reproduce_hive_cascade.sh 172.16.x.x 6001 10
    
    set -euo pipefail
    PROXY_IP="${1:?用法: $0 <proxy_ip> [port] [iterations]}"
    PORT="${2:-6001}"
    ITERATIONS="${3:-10}"
    TIMEOUT_SEC=120
    USER="dump"
    PASS="111"
    DB="external_hive_partition_2000_large"
    
    JOIN_SQL="select d.part_name, count(*) as rowcount from ${DB}.fact_hive_2000 f join ${DB}.dim_part_2000 d on f.part_id = d.part_id where d.part_id in (1, 7, 2000) group by d.part_name order by d.part_name;"
    
    echo "=== Hive Partition Cascade 复现 ==="
    echo "目标: ${PROXY_IP}:${PORT}, 迭代: ${ITERATIONS}, 超时: ${TIMEOUT_SEC}s"
    
    fail_count=0
    for i in $(seq 1 "${ITERATIONS}"); do
        start_time=$(date +%s)
        result=$(timeout "${TIMEOUT_SEC}" mysql -h "${PROXY_IP}" -P "${PORT}" -u"${USER}" -p"${PASS}" --connect-timeout=10 -N -e "${JOIN_SQL}" 2>&1) && rc=0 || rc=$?
        elapsed=$(( $(date +%s) - start_time ))
        if [ $rc -eq 124 ]; then
            echo "  [${i}/${ITERATIONS}] FAIL: 超时 (${TIMEOUT_SEC}s)"
            fail_count=$((fail_count + 1))
        elif [ $rc -ne 0 ]; then
            echo "  [${i}/${ITERATIONS}] FAIL: 错误 (rc=${rc}) ${elapsed}s"
            fail_count=$((fail_count + 1))
        else
            echo "  [${i}/${ITERATIONS}] OK: ${elapsed}s"
        fi
    done
    
    echo "成功: $((ITERATIONS - fail_count))/${ITERATIONS}, 失败: ${fail_count}/${ITERATIONS}"
    [ "${fail_count}" -eq 0 ] && echo "PASS" || echo "FAIL"

    判断标准

    结果 含义
    10/10 全部 OK 修复有效
    有任何 FAIL (超时或错误) 问题仍存在

    注意事项

    • 超时设为 120s(正常应 <10s,120s 足够宽容)
    • 历史复现率约 50%,10 轮迭代足够暴露问题
    • 验证修复时建议跑 3 次脚本(共 30 轮),全部 PASS 才算修复
    • 脚本不需要任何前置 setup,数据已在 COS 上
  7. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    小数据量复现测试

    原始问题是 2000 个分区导致 ~2000 个并发 S3 读取压垮 CN。不确定更少分区是否也能触发。

    下面这个脚本可以用不同分区数测试,找到最小可复现的阈值:

    #!/bin/bash
    # test_partition_threshold.sh — 测试不同分区数下的复现情况
    # 用法: bash test_partition_threshold.sh <proxy_ip> [port]
    #
    # 会依次测试 50/100/200/500/1000/2000 个分区,每个跑 5 轮
    # 找到能稳定复现的最小分区数
    
    set -euo pipefail
    PROXY_IP="${1:?用法: $0 <proxy_ip> [port]}"
    PORT="${2:-6001}"
    USER="dump"
    PASS="111"
    DB="external_hive_partition_2000_large"
    TIMEOUT_SEC=120
    ROUNDS=5
    
    echo "=== 分区数阈值测试 ==="
    echo "目标: ${PROXY_IP}:${PORT}"
    echo ""
    
    for part_count in 50 100 200 500 1000 2000; do
        # 用 part_id 范围控制扫描的分区数
        # part_id 范围 1-2000,取前 part_count 个
        SQL="select d.part_name, count(*) as rowcount \
             from ${DB}.fact_hive_2000 f \
             join ${DB}.dim_part_2000 d on f.part_id = d.part_id \
             where d.part_id between 1 and ${part_count} \
             group by d.part_name order by d.part_name;"
    
        fail=0
        for i in $(seq 1 ${ROUNDS}); do
            start=$(date +%s)
            result=$(timeout ${TIMEOUT_SEC} mysql -h "${PROXY_IP}" -P "${PORT}" \
                     -u"${USER}" -p"${PASS}" --connect-timeout=10 -N -e "${SQL}" 2>&1) && rc=0 || rc=$?
            elapsed=$(( $(date +%s) - start ))
            if [ $rc -eq 124 ]; then
                fail=$((fail + 1))
                echo "  [${part_count}分区] round ${i}: TIMEOUT ${TIMEOUT_SEC}s"
            elif [ $rc -ne 0 ]; then
                fail=$((fail + 1))
                echo "  [${part_count}分区] round ${i}: ERROR rc=${rc} ${elapsed}s"
            else
                echo "  [${part_count}分区] round ${i}: OK ${elapsed}s"
            fi
        done
    
        if [ ${fail} -gt 0 ]; then
            echo ">>> ${part_count} 分区: ${fail}/${ROUNDS} 失败 — 可复现"
        else
            echo ">>> ${part_count} 分区: 0/${ROUNDS} 失败 — 未触发"
        fi
        echo ""
    done

    预期结果

    分区数 并发 S3 读取 预期
    50 ~50 大概率不触发
    100 ~100 可能不触发
    200 ~200 边界
    500 ~500 大概率触发
    1000 ~1000 几乎必定触发
    2000 ~2000 必定触发

    跑完后可以确定最小可复现的分区数,后续验证就用这个数,跑得更快。

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

    kind/bug

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions