Skip to content

[Bug]: 4.2 CLONE resurrects a previously deleted row when another row is deleted from the clone #33079

Done

Description

@LeftHandCold

Existing reports

Related to #32500 and #33043. This case starts with a committed source object and a committed delete. The source stays correct, while the clone resurrects the already deleted row after a separate DELETE. The same result occurs before and after #33043. #29540 concerns a snapshot advance and RowID transfer during an active transaction.

Environment

Reproduced on Linux x86_64 with two CNs, one TN, and a local disk-backed isolated cluster.

Reproduction

Run the following in one session connected to the first CN. All rows are synthetic.

CREATE DATABASE clone_delete_reappears;
USE clone_delete_reappears;
CREATE TABLE src (id INT PRIMARY KEY, a INT);
INSERT INTO src VALUES (1,11), (2,22), (3,33), (4,44);
SELECT mo_ctl('dn','flush','clone_delete_reappears.src');

DELETE FROM src WHERE id=2;
SELECT mo_ctl('dn','flush','clone_delete_reappears.src');
SELECT id FROM src ORDER BY id;

BEGIN;
CREATE TABLE copy_t CLONE src;
SELECT id FROM copy_t ORDER BY id;
DELETE FROM copy_t WHERE id=3;
SELECT id FROM src ORDER BY id;
SELECT id FROM copy_t ORDER BY id;
COMMIT;

Then query the source and clone on both CNs after the commit.

SELECT id FROM clone_delete_reappears.src ORDER BY id;
SELECT id FROM clone_delete_reappears.copy_t ORDER BY id;

Expected and actual

Checkpoint Expected IDs Observed IDs
Source after deleting 2, including after flush 1, 3, 4 1, 3, 4
Clone just after CREATE TABLE CLONE 1, 3, 4 1, 3, 4
Clone after deleting 3 inside the transaction 1, 4 1, 2, 4
Clone after commit on either CN 1, 4 1, 2, 4
Source after commit on either CN 1, 3, 4 1, 3, 4

The source DELETE reports one affected row. The second DELETE targets only id=3 in the clone. No concurrent SQL, secondary index, or same-transaction creation of the source is needed. Four of five locally checked variants produced the same wrong result, including with a secondary index and when cloning an already cloned table. The variant without a source flush before the first DELETE returned the correct result in this fixture.

Investigation and acceptance

The visible change occurs during the first DELETE against the newly cloned table. Check whether rewriting a shared persisted object applies all inherited tombstones when copying the retained rows. The output alone does not establish the internal failure point.

Add a regression that asserts the full row sets before and after the clone DELETE, at commit, and from another CN. Retain #33043's sibling isolation and rollback coverage.

Activity

  1. added
    kind/bug
    on Nov 23, 2026
  2. self-assigned this
    on Nov 23, 2026
  3. added 2 commits that reference this issue on Nov 28, 2026
    785b8ae
    7a6ed59
  4. XuPeng-SH commented on Nov 28, 2026

    @XuPeng-SH
    Contributor

    转 QA:修复已分别合入 main@7a6ed59a08632decebde05ce90ac4d85e872e553(#33405)及 4.2-dev@785b8ae8731b7765362ac4b4952ee1ee0b416baf(#33406)。两条线都在重写克隆对象时应用从源表继承的删除,避免已删除行因换 RowID 重新可见。

    合并前验证:main 的双 CN SQL 回归在恢复旧实现后两侧均复现问题,修复后两侧均通过,mo-tester 59 条通过;4.2-dev 的双 CN 回归及回滚相关定向测试通过,mo-tester 68 条通过,无忽略。main 评审后的分支更新未改 Clone 实现或回归文件。这些是合并前的证据,本轮没有独立运行两个合并后的构建或发布镜像。

    QA 范围:两条线分别核对源表已提交并 flush 删除后,在同一事务内 CLONE 和 DELETE;提交前后以及另一 CN 读到提交后,源表应为 [1, 3, 4]、克隆表应为 [1, 4]。同时保留二级索引、二次克隆、兄弟克隆隔离和失败回滚边界。

  5. Ariznawlll commented on Nov 28, 2026

    @Ariznawlll
    Collaborator

    结论

    测试通过。main与4.2-dev分别完成原始CLONE删除复活复现及必要扩展,本地和两条分支对应Linux MOTR/白盒均通过;回归已分别提交MOTR main与4.2-dev,按授权关闭。

    关键证据

    修复与实际运行版本

    原始复现步骤及每个观察点

    每轮新建隔离数据库:

    CREATE TABLE src(id INT PRIMARY KEY,a INT);
    INSERT INTO src VALUES(1,11),(2,22),(3,33),(4,44);
    SELECT mo_ctl('dn','flush','<fixture>.src');
    DELETE FROM src WHERE id=2;
    SELECT mo_ctl('dn','flush','<fixture>.src');
    SELECT id,a FROM src ORDER BY id;
    BEGIN;
    CREATE TABLE copy_t CLONE src;
    SELECT id,a FROM copy_t ORDER BY id;
    DELETE FROM copy_t WHERE id=3;
    SELECT id,a FROM copy_t ORDER BY id;
    SELECT id,a FROM src ORDER BY id;
    COMMIT;

    实测两个分支每轮均为:

    观察点 精确行集
    源删除2并flush后 (1,11),(3,33),(4,44)
    刚创建CLONE (1,11),(3,33),(4,44)
    在CLONE删除3,提交前 (1,11),(4,44)
    提交后两个CN的新连接读CLONE (1,11),(4,44)
    源表及兄弟CLONE (1,11),(3,33),(4,44)

    原缺陷中的 id=2 没有复活。每处均核对完整主键及 a 值,不只 COUNT(*)。

    扩展和失败后的状态

    每轮四种来源状态:首批flush+删除flush、同条件加二级索引、无首批flush、首批flush但删除尚未flush。每条线三轮,共12组;默认和二级索引路径分别核对:

    • indexed变体用 FORCE INDEX(idx_a) 范围读取同样精确为 (1,11),(4,44),没有幽灵索引行。
    • 从已修改CLONE再次CLONE,再删id=1,只剩 (4,44);上代CLONE和源表均保持正确。
    • (5,55),(1,999) 的重复主键混合INSERT返回1062,目标仍只有1/4,id=5没有部分写入。
    • 对既有CLONE删除4后ROLLBACK,重新读回1/4。
    • 事务内新建CLONE再DELETE后ROLLBACK,该新表应不存在;源表仍1/3/4。
    • 兄弟CLONE在目标写入前创建,目标删除不改变兄弟或源表。

    4.2最初在缺表断言使用了main的1146,实得1064 table ... does not exist。随后用同分支普通不存在表作为对照确认既有错误契约,再按分支准确核对错误码及exist消息并重跑完整三轮。它证明ROLLBACK表确实消失,不属于CLONE修复失败;未把原失败日志抹掉或接受任意错误。

    实际回归和白盒

    • main 正式MOTR total=3 success=3 failed=0 skipped=0,13.19秒;4.2同样3/3,12.99秒。
    • main既有 issue_32500_clone_isolation 与 issue_32500_clone_ownership 邻接回归各三次,合计6/6、171条SQL通过;只是关联回归,不改变其他未分配Issue状态。
    • main TestWorkspaceRewriteTombstoneOffsets、TestCloneDeleteOwnershipAfterCommitTwoCN 各3/3;后者通过两个真实MySQL连接和commitTS/logtail fence核对writer/reader两CN提交后读取。
    • 4.2 TestWorkspaceRewriteTombstoneOffsets、TestCloneRewriteFailureRequiresFullRollback、TestCloneRewriteKeepsPersistedDeletesAcrossCNs 各3/3。
    • tombstone白盒覆盖继承删除、table/object隔离、offset去重且不改输入、取消和缺文件错误。4.2失败恢复白盒真实命中缺失继承tombstone、含糊上传及瞬时清理失败:禁止部分提交、要求整事务回滚、确认替代对象最终回收且源已提交对象仍在。这些是受控文件服务注入,未声称是真机断电/Chaos。

    回归分别追加现有 MOTR main #374 与 MOTR4.2-dev #353,脚本/golden显式分支;4.2加入已有branch-owned daily action,需相关PR合入才实际每日执行。没有往MatrixOne主库提PR。本地975/975、948/948离线工具检查及actionlint/diff均通过。

    两条分支最终Linux结果

    分支 实际官方源码SHA MOTR 白盒
    main 679c314000edc9ca7ef55cc90905a87f44ad2669 新33079加两个32500邻接用例,各3轮,9/9 offset及真实SQL双CN根各3/3
    4.2-dev ea874f3f23cb14f2856d092c87d3c80cba117a97 新33079三轮3/3 offset、失败回滚、跨CN持久删除三个根各3/3
    • main 46127601037,MOTR head 07c0f301b204722f56a80704c03a2eec720627b8:Verify clone delete ownership and inherited tombstones与Verify GeoJSON COPY role and branch recovery unit contracts均SUCCESS。该step强制匹配9/9 SQL及每根3个PASS,版本由真实双CN核对。
    • 4.2 46127599308,MOTR head 61a6d247643f9fa1dd01fa59f58b0bef18158c70,branch-owned composite整体SUCCESS,包含本单MOTR3/3及三个白盒根各3/3。该job普通MOTR服务是单CN;跨CN由既有嵌入式真实MySQL集成核对,另有前述本地两个独立进程的完整三轮,不将其拓扑混写成Linux普通MOTR的独立双进程。
    • 两分支原始删除可见性、错误原子性与回滚必要门槛均完成。main汇总PR仍有其他Issue长耗时检查和独立HashBuild runner配置问题,不写整个PR全绿。
    • 回归脚本/golden分别位于各自MOTR分支;4.2 branch-owned daily action已接入,但每日实际生效依赖先合入#353及main薄调度入口,不将PR CI说成每日已跑。

    待解决点

    本单无未通过项、无未验收项。相关MOTR PR尚待合入,用户已授权验收通过并提交回归后先关闭,稍后自行合入。

    最终结论:测试通过。main与4.2-dev均未再出现已删id=2复活;完整行集、二级索引、二次/兄弟CLONE、重复写入原子性及新旧CLONE回滚均通过,两个分支对应Linux SQL和白盒门槛全部通过。未通过项:无;未验收项:无。回归已分别提交MOTR main #374与4.2-dev #353,按授权关闭。

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

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions