Skip to content

[Bug]: saving DATA BRANCH DIFF with DATETIME crashes the service #31547

Closed

Description

@Ariznawlll

Description

With save_query_result=ON, DATA BRANCH DIFF of a changed DATETIME(6) column terminates the MatrixOne service process. The client loses its connection. The same diff works when saving is OFF, and an ordinary saved SELECT of the same DATETIME value works.

Environment

  • main commit f847803802289b2b2d0df4f0a2f842c2804b823a (git_version() = f847803802)
  • Isolated local standalone, one CN, macOS arm64

Minimal reproduction

CREATE DATABASE branch_datetime_repro;
USE branch_datetime_repro;
CREATE TABLE b (id INT PRIMARY KEY, v DATETIME(6));
INSERT INTO b VALUES (1, '2024-01-01 00:00:00.123456');
DATA BRANCH CREATE TABLE c FROM b;
UPDATE c SET v = '2024-01-02 00:00:00.654321' WHERE id = 1;

SET save_query_result = OFF;
DATA BRANCH DIFF c AGAINST b;
-- Returns c, UPDATE, 1, 2024-01-02 00:00:00.654321

SET save_query_result = ON;
/* save_result */ SELECT v FROM c;
SET @control_qid = last_query_id();
SELECT * FROM result_scan(@control_qid) AS r;
-- Both return the exact DATETIME value with microseconds

DATA BRANCH DIFF c AGAINST b;
-- Connection lost; standalone process exits with code 2

Actual and expected

The server logs panic: interface conversion: interface {} is string, not types.Datetime at pkg/frontend/util.go:1756. The call chain is convertRowsIntoBatch → trySaveQueryResult → satisfyDiffOutputOpt → a goroutine created by diffMergeAgency. The expected result is the same updated row as with result saving OFF, with a saved result that preserves its DATETIME value. A query-result option must not terminate the service.

Stability and controls

  • Reproduced 3/3 in fresh databases qbranchdatetime_04/05/06, each after a separate service restart; all three server processes exited with code 2 and the same panic stack. The initial mixed-type case qbranchprec_01 also hit the same panic, but was not counted among the three minimal runs.
  • OFF control returned the correct updated row in each run. ON ordinary SELECT plus RESULT_SCAN preserved the exact microseconds in runs 05/06. The failure occurs specifically in frontend saving of the branch-diff result.
  • This was tested only on an isolated single-CN deployment; all sessions using that process lost service availability. No data-mutation claim is made from the crash itself.

Code analysis

convertRowsIntoBatch asserts that the frontend row contains types.Datetime. This diff path supplies a string. The assertion happens in a diff worker goroutine, so the panic is not returned as a SQL error and the service exits. This differs from #31498's unsigned integer count assertion and from #31534's explicit unsupported MySQL type error.

Activity

  1. added this to the MO-202610 milestone on Oct 28, 2026
  2. added theissue type on Oct 28, 2026
  3. Ariznawlll commented on Oct 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试不通过。同一结果保存转换缺陷还会影响 TIME(6):保存 DATA BRANCH DIFF 时服务进程退出。这是 #31547 的同根类型扩展,不新建重复 issue。

    关键证据

    • 版本:main@f847803802289b2b2d0df4f0a2f842c2804b823a;本地隔离单 CN 集群。
    • 3/3 新建数据库 qbranchtime_01/02/03 稳定复现:TIME(6) 列从 01:02:03.123456 更新为 04:05:06.654321 后,save_query_result=OFF 的 DIFF 返回正确微秒值;save_query_result=ON 时客户端收到 2013,服务退出码为 2。
    • 正常对照通过:同一 TIME(6) 值的普通 SELECT 结果保存和 RESULT_SCAN 精确返回 04:05:06.654321。
    • 栈稳定指向 pkg/frontend/util.go:1742 的 convertRowsIntoBatch:panic: interface conversion: interface {} is string, not types.Time,上层同样经过 query_result.go:459 和 data_branch_output.go:1378。复现脚本:/private/tmp/mo-explore-run-20261028/data_branch_time_probe.py。

    待解决点

    • 结果保存转换需按实际行值类型安全处理 TIME,不应对 DIFF 输出中的字符串直接断言为 types.Time。
    • 修复回归应同时覆盖 DATETIME(6) 与 TIME(6),并校验微秒值、连接可用性和进程存活。
  4. added a commit that references this issue on Nov 14, 2026
    625865c
  5. XuPeng-SH commented on Nov 14, 2026

    @XuPeng-SH
    Contributor

    QA 交接:已合并修复,待验收

    PR #32456 已合入 main,merge SHA 625865c470631f33da52793a2e2766d63e5a316e,最终 head 86d6fbf32cfb96ed8e0155d6124cec3e568ae4cb。

    证据边界:最终 head 的评审 #32456 (review) 复用 shared build、Ubuntu/x86 UT、arm64 SCA、coverage、PROXY/PESSIMISTIC BVT 成功结论;合并记录 CI Required 成功,队列未重跑 CI。评审只新做 diff check,未新跑 Go/集群,原始 CI/作者日志未供其复核。作者报告定向 BVT 57/57、system_variable 636/636、branch/diff 1976/1976;snapshot 18389/18454,65 项资源准入失败,不能称全目录通过。上述为远端记录和作者报告,本轮没有本地构建或实测。

    修复 DATE/TIME/DATETIME 原生值及文本转换,按声明 scale 解析并保留小数秒,避免保存 DIFF 时直接类型断言导致进程退出。旧评论 6462549743 的 TIME(6) 反例来自旧 main f847803;本次明确包含 TIME 与 DATETIME 回归,不能直接当作合并版本反例。

    QA 建议在隔离实例重复新库 DATETIME(6)/TIME(6) 的 OFF/ON 对照、普通保存 SELECT、RESULT_SCAN 精确微秒读回、NULL/非法类型失败边界,并确认连接和进程存活;补多 CN 验证。不是对其他保存类型或全部 DIFF 问题的验收。

    交 Ariznawlll 验证,保持 open;转测不代表验收通过,本轮未运行测试。

  6. Ariznawlll commented on Nov 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试通过。main 上原 DATETIME/TIME 保存 DIFF 导致服务退出的问题未再复现。

    关键证据

    • 测试版本:官方 main c71e0c6904f444f45c4f4095be0e9f088b0c3b50,包含修复 PR fix: reject invalid global time_zone, save DATA BRANCH DIFF temporal results, reject snapshot-qualified write targets #32456;独立 Linux 容器、1 TN/LogService、双 CN,两个 CN 的 git_version() 均核对为该完整 SHA。未将本结果外推到 4.2-dev。
    • 执行证据:双 CN 验证任务。对应 MOTR 定向步骤成功;前一轮同类定向记录两个 CN 各 15/15、无跳过;本次附加普通保存 SELECT 与失败原子性控制。
    • 回归:MOTR #345,main 专用;PR 已提交、待合入。
    • suite 边界:前一轮 14_issue_regression 931 项中 800 通过、12 失败、119 跳过;12 项失败与更早同版本基线名单一致,不能称整套 CI 全绿。最新一轮结果同为 800 通过、12 失败、119 跳过,失败名单一致。
    • 原始路径和 Happy case:对两个 CN 各重复 3 轮,每轮在 UTC、+05:30、-07:00 三个会话时区,分别比较 save_query_result OFF/ON 的 DATA BRANCH DIFF、RESULT_SCAN 和 INSERT 到目标表的值;DATETIME(6)、TIME(6) 的微秒值以及 DATE 精确一致。
    • Unhappy case:包含 NULL 列,重复主键插入被拒绝且目标表未变;随后查询成功,连接与 CN 保持可用。普通保存 SELECT / RESULT_SCAN 作为对照。
    • 白盒:核对 fix: reject invalid global time_zone, save DATA BRANCH DIFF temporal results, reject snapshot-qualified write targets #32456 将 DIFF 文本时间值按类型和列精度转换,避免原先对 DATETIME/TIME 的直接类型断言 panic。

    待解决点

    • 本结论仅覆盖本问题的时间类型及上述部署范围;未做大数据性能或其他结果类型的泛化验收。
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