Skip to content

[Bug]: ADDTIME and SUBTIME panic on fractional composite TIME strings #28151

Closed

Description

@Ariznawlll

现象

在 MatrixOne main 99ed717b769e261b842c2f17345bd65865fc1470,ADDTIME/SUBTIME 处理带 fractional seconds 的复合 TIME 字符串会触发服务端 panic:

SELECT ADDTIME('1 12:34:56.123456', '01:02:03.500000');
SELECT SUBTIME('1 12:34:56.123456', '01:02:03.500000');

两条语句都返回内部错误,堆栈指向 types.ParseDatetime 的 slice bounds out of range,分别经过 addTimeToString / subTimeFromString。

不带 fractional seconds 的同类字符串不会 panic,但会被错误解释成当前日期的 DATETIME,见 #28147。

期望

非法或超范围输入应返回标准 SQL 结果/错误,不应触发进程级 panic;合法的复合 TIME 字符串应按时间间隔计算并保留小数精度。

影响

单条用户查询即可触发内部错误,破坏连接稳定性,并可能导致 CN 重启或请求失败。

复现信息

  • MatrixOne main: 99ed717b769e261b842c2f17345bd65865fc1470
  • 每条语句重复执行 3 次,结果一致

Activity

  1. added this to the MO-202609 milestone on Sep 4, 2026
  2. added
    kind/bug
    on Sep 4, 2026
  3. added theissue type on Sep 4, 2026
  4. XuPeng-SH commented on Sep 27, 2026

    @XuPeng-SH
    Contributor

    QA handoff after merged PR #28851 (merge a99db843c7b4630a86883addc9424433d93fc2d2). This issue was a non-closing related report; the merge and shared BVT counts are not an independent PASS for this reproducer.

    Latest MatrixOne contract: C05, C08, C18 in the merged temporal design. Fractional composite duration strings must never panic. Valid duration arithmetic returns the exact signed/fractional result; malformed input returns row NULL without an arithmetic overflow warning.

    Please rerun the original reproducer on main at or after the merge and record the exact SHA, deployment, SQL mode/time zone, client path, observed rows/types/NULLs and active warnings or errors. Rerun ADDTIME and SUBTIME from the issue, plus no-fraction, bad-fraction and boundary controls; confirm the service remains usable after any rejection.

    Keep the issue open until the issue-specific acceptance is demonstrated with happy and unhappy controls. If any part still fails, post the exact observed-versus-expected result and return it to development; if it passes, record evidence and close the issue. @Ariznawlll

  5. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • Commit:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 部署方式:本地全新单 CN mo-service,独立数据目录;MySQL 文本协议与 server-side PREPARE
    • 测试日期:2026-10-02

    原问题验证

    按 issue 原始语义在上述 commit 重新执行并重复 3 次。ADDTIME/SUBTIME 的带小数复合 TIME 输入返回精确 signed/fractional 结果,原 panic 未复现。

    Happy Path 覆盖

    覆盖正负值、微秒精度和多行列输入。

    Unhappy Path 覆盖

    覆盖 malformed fractional composite、NULL 与越界;均返回受控 NULL/诊断,无 panic。

    白盒验证

    关联修复 #28851 已进入当前 main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。

    回归测试

    测试证据

    • 精确测试版本:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 当前结果:ADDTIME/SUBTIME 的带小数复合 TIME 输入返回精确 signed/fractional 结果,原 panic 未复现。
    • 回归代码与 golden result 已提交到 MOTR #209;本地全量 14_issue_regression 中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions