Skip to content

[Bug] 30s remote dispatch watchdog can falsely fail slow receiver registration #25816

Description

@Ariznawlll

Summary

Remote dispatch can falsely fail a valid query when receiver registration takes longer than 30 seconds.

The regression was introduced by commit 36016d54a8a5ea4d1bda127e11a402c828538bd7 / #24269. That change replaced the previous 3600-second wait with fixed 30-second watchdogs and introduced the current error:

internal error: dispatch process not registered within 30s, remote CN may have failed

The timeout detects slow registration as if the remote CN had failed. This is timing-sensitive and therefore appears intermittently under slow external scans, JOIN preparation, high concurrency, GC, or storage/network pressure.

This issue tracks the timeout/readiness design regression separately from workload-specific symptom issue #25211.

Regression evidence

A history search for both the error string and timeout constant points to the same first main commit:

36016d54a8a5ea4d1bda127e11a402c828538bd7
fix(pipeline): replace busy-wait polling with channel-based notification (#24269)

Before #24269:

HandleNotifyTimeout = 3600 * time.Second

After #24269:

const waitRegistrationTimeout = 30 * time.Second
const waitRemoteRegTimeout = 30 * time.Second

It also introduced:

"dispatch process not registered within %s, remote CN may have failed"

The PR stated that registration normally happens within seconds. That assumption does not hold for all execution topologies: remote/pre scopes can begin notify processing before the coordinator/local dispatch reaches Dispatch.Prepare and publishes its receiver UUID. Slow Hive external-scan/JOIN preparation can expose this ordering window for longer than 30 seconds.

The later fixes also corroborate incomplete registration coverage:

These fixes cover specific paths, but the fixed watchdog still conflates receiver readiness with remote CN failure.

Intermittent pass/fail evidence

The same Hive Partition job alternates between success and failure, so a one-shot bisect is not reliable:

Run Hive job result
28061543580, job 83097381717 success
28133872754, job 83335832278 failed with dispatch registration timeout
28721408964, job 85236481992 success
28756800333, job 85273758086 failure
28902823580, job 85780232473 success
29054645722, job 86253126494 failed with receiver lifecycle/registration errors
29170188051, job 86594634090 success
29211194235, job 86704634878 failed with dispatch registration timeout

Latest main occurrence

The latest affected path is documented in #25211:

That commit already contains #25682. The same Hive fact/dimension JOIN stopped making progress and hit the client-side 1800-second timeout.

The latest runner log does not expose the inner 30-second dispatch error, so it proves recurrence on the same SQL path but does not by itself prove the latest hang has the identical internal cause. CN logs and a query profile are still required for that run.

Also, #25682 primarily fixes multiple CN services sharing one process in standalone Multi-CN. The TKE reproduction uses separate CN pods/processes, so per-service server isolation does not remove the TKE registration-ordering problem.

Affected 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;

Expected behavior

A valid slow query must not be classified as a remote CN failure merely because receiver registration has not happened within a fixed 30-second wall-clock window.

Remote dispatch should either:

  1. establish an explicit receiver-readiness/registration handshake before remote notify begins; or
  2. start a bounded failure timeout only after the relevant scope is expected to be registration-ready.

The original/root error should be preserved when registration does fail.

Suggested fix direction

  1. Define an explicit lifecycle for receiver creation, registration, attachment, cancellation, completion, and retry.
  2. Publish all coordinator/local receivers before starting any scope goroutine that can notify them.
  3. Do not use a fixed pre-readiness timeout as proof that a remote CN failed.
  4. Add receiver UUID, query/statement ID, source/target CN service, scope topology, and registration/attachment timestamps to logs and metrics.
  5. Add deterministic tests with an injected delay longer than 30 seconds before Dispatch.Prepare.
  6. Run the affected Hive JOIN repeatedly per commit; classify a commit only after multiple attempts because the failure is flaky.
  7. On client timeout, cancel the server query and recreate the connection before executing the next statement.

Related issues and PRs

Activity

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

    @Ariznawlll
    CollaboratorAuthor

    Failure steps from run 29428464735

    Source run: Big Data Test 1Y (main) / 29428464735

    Tested versions:

    Relevant failed job and step

    • Job: Query 1Y / 16 Hive Partition
    • Failed step: Run Test - 16 Hive Partition
    • Step runtime: 2026-07-15 17:32:30 UTC to 19:51:14 UTC
    • Failed case: cases/big_data_test/04_QUERIES/29_external_hive_partition_agg_join.sql
    • Final status: execute_failed, process exit code 1

    The preceding Hive cases completed:

    1. 24_external_hive_parquet_issues.sql
    2. 26_external_hive_partition_scan.sql
    3. 27_external_hive_partition_pruning.sql
    4. 28_external_hive_partition_filepath.sql

    Inside 29_external_hive_partition_agg_join.sql, the first six statements also completed. The sixth statement was the correlated EXISTS query; it completed in 98,976.91 ms. The next statement was the first effective failure.

    First effective failure

    Started at 2026-07-16 01:51:12 +08:00 and reached the client-side 1800-second timeout at 02:21:12 +08:00:

    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;

    Runner error:

    [ERROR] [execute_sql.py:147, execute]
    Execution timeout after 1800s, continues to execute the next sql...
    

    Subsequent timeouts

    The runner then continued on the same PyMySQL connection/cursor:

    Start (+08:00) SQL Result
    02:21:12 fact table self-JOIN on part_id and col_uuid timeout at 02:51:12 after 1800s
    02:51:12 two-branch partition count UNION ALL timeout at 03:21:12 after 1800s
    03:21:12 GROUP BY part_id ORDER BY rowcount DESC timeout at 03:51:12 after 1800s

    Final log:

    File .../29_external_hive_partition_agg_join.sql has failures [execute_failed], continuing with next file...
    Some tests failed, see above for details
    Process completed with exit code 1.
    

    Only the first fact/dimension JOIN should currently be classified as the primary failure. func_timeout returns control to the runner without proving that the server-side query was cancelled, and the runner reuses the same connection/cursor. The following three timeouts can therefore be cascading effects and should not be counted as four independent MatrixOne failures.

    Other failed job in the same run

    The run also contains an independent failure:

    • Job: Query 1Y / 12 Window Function
    • Failed step: Run Test - 12 Window Function
    • Cause: result comparison failure in 07_WINDOW/11_combo.sql for the avg_vol_20d / vol_ratio query
    • Status: compare_failed, exit code 1

    That Window Function comparison failure is unrelated to this remote-dispatch/Hive issue and is listed only to account for every failed job in the workflow run.

  5. self-assigned this
    on Jul 17, 2026
  6. added a commit that references this issue on Jul 17, 2026
    7ffd26c
  7. XuPeng-SH commented on Jul 21, 2026

    @XuPeng-SH
    Contributor

    should be fixed

  8. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    在最新 main 分支完成修复点验证,结论:固定 30 秒 watchdog 导致慢注册被误判失败的问题已在代码层面修复。

    测试版本:

    测试过程:

    1. 验证 receiver 尚未注册时,等待逻辑能够越过原先的固定 admission timeout,直到 receiver 真正发布或 query context 取消,不再在固定墙钟时间后直接返回“remote CN may have failed”。
    2. 验证多个 remote receiver 只完成部分注册时,query cancellation 可以及时中止剩余等待,不发生永久阻塞。
    3. 验证 registration channel 关闭、owner 已关闭、owner cleanup 先于 attach 等终态均能唤醒等待者并返回明确错误。
    4. 验证 receiver 从 ready 到 attached 的正常状态转换,以及晚到 publication 只唤醒对应 UUID 的 waiter。
    5. 验证一个共享 waiter 被取消时不会破坏同 UUID 的其他 waiter;旧 generation 的取消也不能删除后来注册的新 generation。
    6. 验证 receiver attach 后的消息取消能够传递给 owning process。
    7. 验证新客户端对旧服务端的 typed NotRegistered legacy retry:可以越过旧的固定等待阈值继续重试,但必须受 query context 限制;无关错误不会进入无限 retry。
    8. 普通模式重复执行 5 轮,并使用 -race 重复执行 3 轮。

    覆盖的核心测试:

    • TestAttachProcByUuidOrWaitPreservesTerminalOwner
    • TestCancelConsumedDispatchRegistrationCancelsOwnerProcess
    • Test_GetProcByUuid_CancellationDoesNotPoisonLaterRegistration
    • Test_GetProcByUuid_WaitsPastFormerAdmissionLimitForRegistration
    • TestWaitRemoteRegsReadyCancellationAfterPartialRegistration
    • TestWaitRemoteRegsReadyFailsWhenRegistrationChannelCloses
    • TestWaitRemoteRegsReadyWaitsPastFormerAdmissionLimit
    • TestHandlePrepareDoneNotifyObservesMessageCancellationAfterAttach
    • TestSendNotifyMessageLegacyRetryStopsAtQueryCancellation
    • TestSendNotifyMessageLegacyRetryWaitsPastFormerAdmissionLimit
    • TestSendNotifyMessageSuccessfulAttachUsesQueryContext

    测试结果:

    • 11 个核心场景普通模式各执行 5 轮,全部通过。
    • 相同场景在 -race 下各执行 3 轮,全部通过。
    • 未出现固定超时误判、等待无法取消、receiver generation 相互污染或数据竞争。
    • 当前实现中已不存在原来的 waitRegistrationTimeout = 30s / waitRemoteRegTimeout = 30s 作为 receiver readiness 失败依据,等待由 receiver 生命周期和 query/connection cancellation 驱动。

    验证边界:
    本轮完成的是可确定覆盖原 timeout/readiness 逻辑的代码级回归,没有重新触发 issue 中的 Hive 大数据/TKE 端到端 SQL。因此可以确认固定 30 秒误判的代码路径已修复;实际 Hive 长查询链路仍由后续 big-data/nightly 继续观察。

  9. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    big-data中的hive partition需要再观察一下

  10. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    CN 日志验证:7/15 和 7/20 两次 run 的对比

    最新测试job:https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29764908174

    对 7/15 run(本 issue comment 中分析的那次)和 7/20 run 分别查了 CN server Loki 日志,结论如下:

    7/15 run (29428464735, commit 0d8111a)

    CN 日志中两种错误同时存在:

    1. remote receiver not ready within 30s(本 issue 描述的 30s watchdog 错误):

    CN 6z9sk, 17:51:42 UTC
    "error: internal error: remote receiver not ready within 30s, remote CN may have failed"
    

    2. 全集群 i/o timeout 级联:

    • CN 6z9sk (10.143.116.192): 从 17:50:21 开始对所有节点 i/o timeout
    • CN kv7s2 (10.143.116.193): 从 17:50:02 开始对所有节点 i/o timeout
    • mo.table.stats.task 每 30s 报 waited err another 30s, total=103, left=103
    • cn-backend 连接互相断开:use of closed network connection

    7/20 run (29764908174, commit 0102f7b)

    CN 日志中只有 i/o timeout 级联,没有 30s 错误:

    • 3 个 CN (trrnj, sj7tp, v89m9) 全部同时 i/o timeout
    • messageBoard length: 0, waiting message timeout
    • 没有 remote receiver not ready within 30s

    原因:commit 0102f7b 已包含 #25820 修复(lifecycle-driven 等待取代固定 30s watchdog),所以 30s 误报不再出现。但底层的 CN 资源耗尽问题仍在,查询从"30s 报错退出"变成了"无限 hang 到客户端 1800s 超时"。

    根因链

    Hive 2000 分区外部扫描耗尽 CN 资源(根因)
      → 全集群 CN 互相 i/o timeout(所有 CN 无法响应任何连接)
      → 修复前 (#25820 之前):30s watchdog 误判为 "remote CN may have failed"(本 issue 的症状)
      → 修复后 (#25820 之后):不再误报 30s,但查询仍然 hang 直到客户端超时
    

    本 issue 的 30s watchdog 修复 (#25820) 是正确的——它消除了误报。但 Hive 外部扫描导致的 CN 资源耗尽是更深层的根因,单独追踪在 #25980。

    建议

    本 issue 可以在 #25820 验证通过后关闭(30s 误报已修),Hive 扫描资源耗尽问题在 #25980 继续跟踪。

  11. added a commit that references this issue on Jul 23, 2026
    ebd05ba
  12. Ariznawlll commented on Jul 27, 2026

    @Ariznawlll
    CollaboratorAuthor
  13. added 6 commits that reference this issue on Sep 17, 2026
    ea43316
    af5754b
    cc6679a
    f5e1fd6
    fe2b4a5
    35138fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions