Skip to content

[Bug]: DELETE on a transaction-local CLONE can delete rows from a different clone #32500

Done

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

The closest report, #32247, concerns stale secondary-index entries after DELETE/UPDATE followed by COPY ALTER. This report shows a different user-visible failure: DELETE from one table changes the rows in a different cloned table. No ALTER is needed.

Branch Name

4.2-dev; main needs runtime confirmation.

Commit ID

Reproduced on unmodified 4.2-dev a7bc2008e9236708fee0328376f2c2c6b6f0d3fc. The relevant disttae transaction and table implementation files have no changes between that revision and 4.2-dev fd3999aefe46030a5deeafe4bc139592464a7b3b. This does not substitute for a runtime test of the latter revision.

Other Environment Information

Local isolated cluster, pessimistic transactions with RC isolation configured on CN and pessimistic transactions on TN. One SQL session, no concurrent workload. The CN and TN run the tested 4.2-dev binary; the log service uses the 4.2.6 release binary.

Actual Behavior

Deleting id=1 from clone a leaves that row in a and removes it from the separate clone b. COMMIT succeeds and the same incorrect results remain visible after COMMIT in the session:

Table Expected IDs Actual IDs
original 1, 2, 3 1, 2, 3
a 2, 3 1, 2, 3
b 1, 2, 3 2, 3

An UPDATE of a was also observed to retain both the old and new version of the updated row in a separate pessimistic RC test. These are data correctness issues, not merely a slow query.

Expected Behavior

Each table must have independent logical contents after CLONE. DELETE and UPDATE must affect only their target table, both within the transaction and after COMMIT.

Steps to Reproduce

Run in a disposable database, using one session:

CREATE DATABASE clone_bug;
BEGIN;
CREATE TABLE clone_bug.original(id INT PRIMARY KEY, a INT, b INT);
INSERT INTO clone_bug.original VALUES (1,10,100),(2,20,200),(3,30,300);
CREATE INDEX ia ON clone_bug.original(a);
CREATE TABLE clone_bug.a CLONE clone_bug.original;
CREATE TABLE clone_bug.b CLONE clone_bug.a;
DELETE FROM clone_bug.a WHERE id=1;
SELECT id FROM clone_bug.original ORDER BY id;
SELECT id FROM clone_bug.a ORDER BY id;
SELECT id FROM clone_bug.b ORDER BY id;
COMMIT;
SELECT id FROM clone_bug.original ORDER BY id;
SELECT id FROM clone_bug.a ORDER BY id;
SELECT id FROM clone_bug.b ORDER BY id;

Additional information

Investigation points to transaction-local clones sharing a CN object while the transaction's cnObjsSummary is keyed by object ID, allowing later registration to replace table ownership. Deletes are tracked by object/block and offsets without retaining sufficient logical-table ownership; subsequent compaction can therefore apply them to a different clone. This is an investigation lead and should be verified against all object lifecycle paths before choosing a fix.

Latest inspected main (4c701ab3da4d2c36e9845b2d72c3c74436b87b88) contains the corresponding object-summary and delete tracking structures, so it is potentially affected; actual main behavior has not yet been reproduced. Verify both branches, including committed results, multiple clones, UPDATE/DELETE, rollback, persisted vs transaction-local objects, and index consistency.

Activity

  1. added
    kind/bug
    on Nov 10, 2026
  2. self-assigned this
    on Nov 10, 2026
  3. added
    severity/s0
    and removed on Nov 10, 2026
  4. added 2 commits that reference this issue on Nov 12, 2026
    00b402e
    a626dd0
  5. XuPeng-SH commented on Nov 13, 2026

    @XuPeng-SH
    ContributorAuthor

    QA 交接(main,待验证,不代表验收通过)

    #32555 已合入 main,merge SHA a626dd045a656c801b6730732adc16df056379d3。修复将事务 workspace 的 CN object summary 和 deleted-block 跟踪限定到逻辑 table ID,并贯穿读过滤、compaction、rewrite/publication 与回滚;物理对象仍可共享,DELETE/UPDATE 不应跨逻辑 clone 生效。

    完整 issue/PR 讨论与修复范围核对未见当前适用的已验证反例或未完开发 follow-up。后续性能修正使用已知 batch 长度预分配和 pass-local lookup,未取消按表所有权。最新记录的 评审 在 92c38f1758712e7be357ca57bb8027b88d041453 报告 762 个 disttae tests normal/race 通过、10 个 focused tests、867 次 adaptive race repetitions、两个 engine recovery tests 和 vet 通过。作者另外报告多 clone 链 20/20、多块变体 16/16 以及后续版本 SQL 15/15;这些是各自版本的远端报告,不是本轮实测或合并 SHA 的新运行。

    限制:本轮未构建/运行产品 SQL、race 或基准;公开 SQL 和性能数据在评审中仍为作者报告,原始日志未独立核验。组件成本和预分配改善不代表端到端性能保证,旧错误 baseline 覆盖丢失的 clone ownership 不能作为语义等价性能对照。原 issue 在 4.2-dev 复现;本次仅交接 main 修复,不宣称 4.2 已修复,也不自动要求 backport。

    QA 建议在包含该 merge SHA 的明确 server/config 上复验原 pessimistic RC 场景:original→a→b(及更长链)的独立/重叠 DELETE、同一行不同 UPDATE、COMMIT 前后及 ROLLBACK 的独立结果;补充多块、NULL、二级索引一致性、事务内与已持久化对象、compaction/error/cleanup 边界,以及单表/clone-heavy 资源与性能对照。以每个逻辑表完整结果为 oracle,不仅看 row count,也不只检查事务内可见性。

    交 Ariznawlll 验证,issue 保持 open。

  6. Ariznawlll commented on Nov 14, 2026

    @Ariznawlll
    Collaborator

    结论

    测试不通过。最新 4.2-dev 仍可复现事务内 CLONE 表之间的删除串表:删除目标表的一行未生效,另一张 clone 的对应行却被删除,提交后错误仍然存在。

    关键证据

    • 版本:官方 4.2-dev@d7931234da4274010bfd2b900c6e349da2fdf2fa;隔离 Linux 环境、1 LogService / 1 TN / 2 CN。两个 SQL 入口均核对完整 git_version(),并通过 mo_catalog.mo_transactions 确认事务模式为 Pessimistic / RC。
    • 按原始步骤在事务中创建 original 并写入 3 行、创建二级索引、依次 CLONE 为 a 和 b,对 a 执行 DELETE WHERE id=1。两个 CN 各 3 次,共 6/6 复现。
    • 每次提交前和提交后,实际 original=[1,2,3]、a=[1,2,3]、b=[2,3];预期分别为 [1,2,3]、[2,3]、[1,2,3]。独立非 CLONE 表执行同样 DELETE 后得到 [2,3],正常对照通过。
    • 运行日志和结果 artifact 保存了 6 轮表内容及事务模式。该 job 另一个 [Performance]: Single-row IN subquery under OR causes ~61k wide-row backfills before FOR UPDATE #32552 步骤因测试错误地要求 main 的 INDEX 计划而失败,该断言失败与本项 DELETE 串表是两个独立结果。
    • 关联修复 #32555 已合入 main;本次实测不能证明它已在 4.2-dev 生效。

    待解决点

    • 请研发处理 4.2-dev 的逻辑表所有权问题,并在修复后复测原始 DELETE、UPDATE、多级 clone、提交/回滚及索引一致性。当前不将失败结果录为回归基线。
  7. added 2 commits that reference this issue on Nov 21, 2026
    6c05e42
    e218f94
  8. Ariznawlll commented on Nov 29, 2026

    @Ariznawlll
    Collaborator

    结论

    未完成验收。原始串表反例和本轮功能扩展在 main、4.2-dev 均通过;整体专项验收尚未完成。此前评论中的旧 4.2-dev 失败不再代表本次冻结版本结果。

    关键证据

    1. 原步骤 BEGIN 内创建 original、写3行、建二级索引、依次 CLONE a/b、DELETE a.id=1。main 与4.2各两 CN×3轮,每分支6/6。提交前、提交后均精确得到 original=[1,2,3], a=[2,3], b=[1,2,3]。
    2. 每分支另外3轮执行既有完整扩展脚本:a DELETE+UPDATE、original→a→b→c→d 长链、不同 clone 对同一行独立删除/更新、NULL值、既有表回滚、新建clone连同其修改整体回滚、索引谓词完整行集校验及另一个 CN 提交后读回,全部通过。
    3. 事务内源表2万行,跨8192/8193/16384等位置分别DELETE和UPDATE;对每个clone完整逐行比对,非仅COUNT。源表flush后等待 metadata_scan 实际行数2万,并用 manifest 确认至少2个真实物理block,再CLONE并独立DML。每分支3/3通过,全部原始行/修改行/兄弟表保持预期。
    4. 分支回归:main原用例仍在现有MOTR #374;4.2专属同名SQL/golden已追加现有MOTR #353,明确target-branch=4.2-dev,本地正式MOTR 3/3。main薄调度显式checkout MOTR 4.2-dev并运行该用例。合入前不声明每日已生效。
    5. 4.2新CI尚在运行。新增一个用例使分支清单584→585,初次工具CI因此失败;已保留失败并补清单数量和新用例显式断言,本地branch-targeting 9/9。该失败是回归库存断言,不是clone数据断言。

    待解决点

    还需完成当前版本的定向race/错误清理门槛与资源、单表/clone-heavy可比性能检查,并回读最新CI。2万行正确性不替代性能验收;不宣称本轮重跑了研发报告中的762项全包测试。

    最终结论:未完成验收。未完成项:当前专项race/错误清理、可比资源性能及最新CI;已通过:两分支原始复现各6/6、完整2万行功能扩展各3/3;本轮已确认产品失败:无。本次不关闭、不改派。

  9. Ariznawlll commented on Dec 1, 2026

    @Ariznawlll
    Collaborator

    已在当前官方 main ba6081a 完成原场景与回归闭环,开测/结束官方分支 SHA 一致。

    • 精确源码构建通过;测试二进制 SHA-256:a856cb87a5b5af72d1b4aa9536a13919e8b46c819adc5f25688d9742f98a0848;43181/43182 两个独立 CN 的运行时 git_version() 均核对该 SHA。
    • native -race:13 个相关测试根 ×10,共 130/130 PASS,无 race/FAIL/SKIP;30 条 benchmark 样本完整。
    • 两个 CN 各执行原始删除、16 层 deep chain、持久化 source 三组 Python 场景 ×3,共 6/6 PASS。覆盖 transaction-local CLONE 间 DELETE/UPDATE 隔离、提交/回滚、本地/对端完整行集和索引控制。
    • 两个 CN 各执行两项 MOTR 用例 ×3,共 12/12 PASS。
    • 资源/性能对照完整:CLONE 与 single 各 3 轮,提交、DML、总耗时、CPU 和 peak RSS 均记录;CLONE 总耗时中位数 3.248s,single 0.277s。
    • 独立 main MOTR 交付:matrixorigin/motr#396,head d4cac3039421ae1aaf3394fc287e6b978f3ec9da;本 Issue 定向双 CN rename 检查已 SUCCESS。未叠加旧 PR374/353。

    证据:qa-32500/main-ba608-full/(identity、native-race10、6 份 Python、双 CN MOTR、performance、benchmark 及 SHA256SUMS)。最终回执:QA32500_MAIN_BA608_FULL_LOCAL_PASS native=130 python=6 motr=12 performance=6 benchmark_lines=30。

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

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions