Skip to content

[Bug]: mo-service ignores -max-processor because the flag is read before flag.Parse #32078

Closed

Description

@slyunnn

Description

mo-service -max-processor N silently leaves the runtime and planner worker limit unchanged. The flag is inspected before command-line parsing, while its value is still the registered default 0.

Environment

Reproduction

Start a fresh owned cluster with a normal launcher manifest and conflicting explicit limits.

GOMAXPROCS=4 mo-service -launch <test-launch.toml> -with-proxy -max-processor 24

Observe the runtime through the existing QueryService GOMAXPROCS command with request value 0. On a sufficiently large persisted table, also inspect EXPLAIN PHYPLAN SELECT * FROM wide with max_dop=0.

Actual Result

  • The process command line includes -max-processor 24.
  • Startup reports runtime.GOMAXPROCS(4) and keeps 4.
  • A QueryService read returns 4.
  • The physical scan uses mcpu: 4 and four normal scan scopes.
  • As a control, sending the existing QueryService GOMAXPROCS command with 24 to the same process changes the next read to 24. This confirms that the runtime can accept the requested value and that the CLI path is the missing transition.

The control response sequence was read=4, set(24) previous=4, read=24. A second CN read also returned 24, as expected for the shared launcher process.

Expected Result

An explicit supported -max-processor value should be applied after parsing, or rejected with a clear error. It must not silently retain a conflicting inherited limit. Runtime/planner worker evidence must agree with the accepted startup configuration.

Code Evidence

cmd/mo-service/main.go registers maxProcessor with default 0, then executes the following order.

func main() {
    if *maxProcessor > 0 {
        system.SetGoMaxProcs(*maxProcessor)
    }
    flag.Parse()
    // ...
}

The only read of this flag is before flag.Parse(). The positive branch is unreachable for normal CLI input because the registered pointer still contains 0. Compile obtains its worker budget from system.GoMaxProcs(), so the ignored setting also affects query planning. The dynamic-cluster launcher passes this flag for its configured CPU count as well.

Scope And Suggested Regression

This is a separate startup-configuration bug. #30575 remains responsible for streaming payload residency.

Use conflicting environment/CLI limits and assert the runtime value after real startup. Cover a lower explicit value, a higher explicit value, omitted/zero options and the dynamic launcher. A command-line-string assertion alone would miss this defect.

Searched open and closed issues for max-processor, maxProcessor and GOMAXPROCS with flag. No matching report was found.

Activity

  1. added
    kind/bug
    on Nov 3, 2026
  2. added theissue type on Nov 3, 2026
  3. added this to the MO-202611 milestone on Nov 3, 2026
  4. assigned and unassigned on Nov 5, 2026
  5. added a commit that references this issue on Nov 6, 2026
    bfdf875
  6. XuPeng-SH commented on Nov 6, 2026

    @XuPeng-SH
    Contributor

    QA 交接:PR #32337 已于 2026-11-06 14:40:17 UTC 合入 main,merge SHA bfdf875816929653ad2ff3e3c403943c7afc4645,最终 PR head c4a0dde1645e34a41fb2bc4d39422ad0cb841d5a。

    修复范围:在 flag.Parse() 之后应用正数 -max-processor,通过现有 setter 同时更新 Go runtime 和 system.GoMaxProcs() 缓存,供编译器读取 worker capacity。省略、0 和负数继续保留初始化策略。动态 CN 子进程命令仅提取为函数,生成参数保持等价。本项不包含 #30575 的流式载荷驻留修复,也不承诺物理 DOP 或性能线性提升。

    证据与限制:

    • 已完整读取 issue 正文、空评论列表、已合并 PR 返回的 426 行新增/10 行删除及 4 条评论/评审。旧复现针对 dd2499cdcdf2722848851d4debca6cd6c66b4751,没有发现适用于本次修复的当前反例或未完成开发 follow-up。
    • 作者报告在 Linux/amd64、main dfc3ab0e382d7c21ca66aa1a03744b0c48c9d7ac 加五文件补丁上完成 pre-fix 失败/post-fix 通过、cmd/mo-service 169 项无失败/跳过,以及限定范围 err-check/SCA。私有服务两阶段 startup runtime/cache 为 4/4 与 8/8,20,000 行查询 COUNT/SUM 与独立公式一致,QueryService 为 read 8 / set previous 8 / read 6;服务退出和 TCP/UDP 清理报告通过。两阶段物理扫描预算均为 1,不能据此声称 DOP 扩展或性能收益。
    • 评审者在旧 head 6a37add27989f83c9e60d8ed61d71115e8745555 报告 Linux Go 1.27.1 的 169 项测试、单 CPU affinity、四项旧代码失败对照及 vet/格式检查通过;其初次依赖准备超时发生在测试前,后续恢复后成功。非 Linux 和作者整服务 SQL/RPC 未由评审独立复跑。Mergify 另记录最终合并门禁 CI Required 成功,旧 head 逐项结果不能冒充最终 head 重跑。本轮未运行本地/集群测试,转测不代表验收通过。

    建议 QA 在上述 merge 或包含它的官方构建上用冲突的环境值和 CLI 参数核验:更低/更高正值覆盖 runtime 与缓存,省略/0/负值保留真实初始化对照,动态 launcher 的实际子进程收到并应用 CpuCount,Linux 单 CPU affinity/cpuset 与原报告 macOS/arm64 场景均覆盖。尽量在 QueryService 调用前记录 runtime/cache,避免 read(0) 经 setter 重同步缓存而掩盖启动状态。提交的动态参数回归运行真实 main 入口但停在缺失配置处、排除了 debug listener,完整动态服务启动/重启仍可补测。查询结果正确性、可用 worker budget 和实际物理 DOP 应分别记录,不把“配置上限为 N”写成“每条查询使用 N 路并行”。

    按已合并修复范围交由 @Ariznawlll 转测,保留 issue 开放,等待 QA 结论。

  7. slyunnn commented on Nov 9, 2026

    @slyunnn
    Author

    Regression and extended verification for #32078 (2026-11-09)

    Verification Environment

    • Frozen MatrixOne origin/main at test start, 6a2b29954749d5a47820ed429cfa8a6c4793682f — fix(parser): allow native PREPARE of DESC/DESCRIBE (#32399). A fresh native build, binary metadata and SQL git_version() agreed.
    • Go 1.27.1, original macOS arm64 platform with 12 logical CPUs, plus Linux amd64 with an actual single-CPU affinity subprocess. Linux targeted execution used an isolated environment because the available Actions entries had no matching native-startup selection.
    • Tested 2 CN / 1 TN / 1 Log service / Proxy first in one native launcher process, then with two independently launched CN child processes. Proxy 127.0.0.1:6001, CN1 127.0.0.1:16001 and CN2 127.0.0.1:16002 were connectable and each executed actual SQL. Clients used PyMySQL TCP COM_QUERY and native Go QueryService RPC.

    What Was Covered

    • OK — Production-main subprocesses verified lower/higher positive overrides against conflicting inherited limits. Omitted, 0 and negative options preserved the observed initialization baseline. Runtime and system.GoMaxProcs() were witnessed before any QueryService read could resynchronize the cache.
    • OK — Linux single-CPU affinity verified the initialized baseline and explicit positive override. All 8 focused Linux test/subtest results passed. The Linux-only case was skipped on macOS and executed successfully on Linux.
    • OK — Complete macOS service and system packages passed with 165 and 62 test/subtest passes. A pre-fix ordering overlay failed lower/higher and dynamic-child assertions with stale runtime/cache values of 4.
    • OK — Real startup with GOMAXPROCS=4 and CLI values 24 and 2 produced the requested startup transitions and double-CN RPC readings. Checked RPC set/previous/read/restore behavior.
    • OK — Persisted 196,608-row wide-table COUNT/SUM and EXPLAIN PHYPLAN SELECT * ran through all three endpoints under both limits. Physical scans selected mcpu: 1 in this fixture. No DOP expansion or linear speedup is claimed.
    • OK — Real dynamic launcher children each received and applied cpu-count=24. Changing one child's runtime left the other at 24. Each CN was stopped and restarted through the launcher, replacement PIDs were verified, and both new children again applied 24. Query results remained correct through all three endpoints after each restart.
    • Not covered — A production throughput SLA or a guarantee that every query uses the configured CPU count.

    Findings

    Fix bfdf875816929653ad2ff3e3c403943c7afc4645, fix(mo-service): apply max-processor after flag parsing, applies the positive CLI option after parsing through the existing runtime/cache setter. Fix PR #32337

    Dynamic restart testing found an independent control-listener defect. The configured control address was ignored, so restart verification used the actual listener owned by the test launcher. That defect has its own report and does not change the verified CPU-option result. Control-listener issue #32421

    The independent build-guard failure was also recorded and worked around through the environment without changing service source. Build issue #32420

    MOTR / BVT Coverage

    Reused cmd/mo-service/max_processor_test.go and the platform-specific affinity helpers, supplemented by real service/RPC/SQL and dynamic-child restart checks. These are process-startup invariants covered by existing regressions, so no duplicate SQL-only MOTR case was added. Startup and restart variants ran serially because they share process-global settings and listener ports. The BVT runner's cleanup removed the first temporary wide-table database, so the low-limit fixture was recreated after BVT completed. Owned services and child processes were stopped.

    Final Conclusion

    Fixed for CLI CPU-option application on the tested main build, including real dynamic CN launch and restart.

    Large-data regression is unnecessary for the flag-parsing defect. The persisted wide-table fixture supplies supplemental query correctness and observed-plan evidence. Increasing data solely to force a particular DOP is unnecessary.

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions