Repository navigation
Description
Description
在在线 DROP INDEX 与并发 autocommit UPDATE 重叠后,已经提交的旧 UPDATE 版本重新可见,基表出现重复复合主键。该路径在后续的合法/非法 ADD UNIQUE INDEX 之前已经失败,因此它不能归因于唯一索引拒绝或其清理路径。
Environment
- Branch:
main - Commit:
1f9e501594509fb5d2e0284833faf8c3426e2285 - Deployment: TKE distributed deployment, 3 CN;
mo-bench-tke.yaml. - Test date: 2026-08-17
Steps to reproduce
-
创建带复合主键
(tenant_id, row_id)、一个唯一二级索引和两个普通二级索引的表;写入 300,000 行,tenant_id = row_id % 48,row_id与external_key均全局唯一。 -
启动 8 个独立 autocommit writer,分别持续更新 tenant
4, 15, 26, 37, 0, 11, 22, 33。UPDATE 仅修改非主键列status/category/amount/version/payload/updated_at。 -
在 writer 与 DDL 真实重叠时,在线执行 ADD INDEX;停止该轮 writer 并审计基表。该阶段通过。
-
再启动同样的 8 个 writer,在重叠窗口内执行:
ALTER TABLE idx_ddl_probe DROP INDEX idx_ddl_row_tenant_reverse;
-
DDL 成功后,使用新 autocommit 连接执行:
SELECT COUNT(*) FROM ( SELECT tenant_id, row_id FROM idx_ddl_probe GROUP BY tenant_id, row_id HAVING COUNT(*) > 1 ) duplicate_keys;
完整可执行回归脚本和参数见 mo-nightly-regression PR #1365:--rows 300000 --writers 8 --writer-seconds 8 --generations 10 --ddl-timeout 180。
Actual behavior
第一个 generation 在 DROP INDEX 后立即失败:
generation=1 setup=PASS
generation=1 add_index=PASS
issue=26804 status=FAIL cause=duplicate primary-key groups: 50000
AssertionError: duplicate primary-key groups: 50000
50,000 = 8 × (300,000 / 48),精确对应 8 个 writer 覆盖的 tenant 行数。writer 从未修改主键列,DDL 前审计为 0 个重复主键分组。
Expected behavior
在线 ADD/DROP INDEX 与并发 UPDATE 不得改变已提交版本的可见性。DDL 成功或失败后,基表均应保持 300,000 个逻辑主键,重复 (tenant_id, row_id) 分组必须为 0;后续 UNIQUE DDL 不应成为发现数据损坏的前置条件。
Stability and controls
- Reproducer: TKE
main两次独立 CI 运行均在 generation 1 复现同一50,000个重复主键分组:43923c5e64abdc174f82ef4055ca653e501c3d34(修复 fix(tae): fail closed on transferred tombstone writes #26905 之后 64 commits)1f9e501594509fb5d2e0284833faf8c3426e2285(修复 fix(tae): fail closed on transferred tombstone writes #26905 之后 101 commits)
- Control: 同一 300,000 行、8 writer、10 generation 的单 CN 隔离运行已全部通过;该差异表明跨 CN 并发 DDL/DML 时序是必要条件之一,而非初始化数据或审计 SQL 的错误。
- Fixture checks: 每次失败前
setup=PASS和add_index=PASS;脚本要求每个 writer 至少一次成功 UPDATE 且至少一次 UPDATE 与 DDL 重叠。运行环境、Python 依赖及脚本启动均成功。 - Data integrity: 失败发生在基表主键完整性 gate,脚本立即停止,避免在已损坏的数据上继续执行 UNIQUE DDL 或掩盖根因。
Evidence
- Official-main failing CI job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/32017014626/job/95350892463
- Independent earlier failing CI job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31786586823/job/94725032612
- Existing regression PR: https://github.com/matrixorigin/mo-nightly-regression/pull/1365
Code analysis
PR #26905 (c3ba9c7df14388956cb38d78681c6c35b75c42b8) fixed transferred tombstone write/sync failures. Both failing main commits contain that fix. The new evidence therefore indicates an uncovered distributed concurrent-DROP path or another cross-CN version/tombstone visibility path. This is a hypothesis; the black-box evidence above establishes incorrect committed-data visibility.
Regression coverage
Keep the existing #26804 scenario in nightly big-data/concurrent regression. Do not change its expected result or reduce scale while the product remains failing. After the fix, retain the ADD INDEX and DROP INDEX phase-level audits separately so this DROP-triggered regression is caught before UNIQUE DDL.
Related
- Closed source issue: [Bug]: Failed ADD UNIQUE resurrects UPDATE versions and creates duplicate primary keys #26804
- Earlier fix PR: fix(tae): fail closed on transferred tombstone writes #26905
- This report is intentionally scoped to the DROP INDEX boundary: the failing run never reaches the later valid or intentionally invalid UNIQUE index operations.
Activity
Ariznawlll commentedon Aug 21, 2026
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/32464408838/job/96721465657
最新main已修复
Ariznawlll commentedon Aug 24, 2026
两次 CI 对比分析结论
对比测试:
dc403fbac6a09c77ac93bb023fe83056308a038b。344d852ac3288e391a3ae6be3e3c7108caf2b75d。两次测试使用的回归脚本、workflow 和 TKE 配置完全一致:
script/issue_26804_online_index_race.pyblob 均为0708f4dbf431988efca60cae28ed52a9b8495bcd;reuse_regression_test.yamlblob 均为18f45e10abd08b06a083ee8fe060d9b5f0f61a69;mo-bench-tke.yamlblob 均为1e0a1ebecfb88825eb1b2f4b352d414849778d0d;关键差异是执行环境和 MatrixOne 版本:
dc403fba比成功版本344d852a领先 41 个 MatrixOne commit,因此两次运行不是严格的单变量实验。本次失败阶段为:
堆栈位于
run_generation()第 789 行,对应 ADD INDEX 完成后的第二个 writer window。执行顺序为:add_index=PASS;writer readiness timeout;因此这次没有复现 #27249 描述的“DROP INDEX 后重复主键”问题:ADD INDEX 及其后的完整性检查均已通过,而目标 DROP INDEX 还没有发出,测试已经因为后续 UPDATE 响应过慢而终止。
第二轮 UPDATE 比第一轮更重:ADD INDEX 后新增了
(status, category, amount, row_id, tenant_id)宽索引,而 writer 正好修改status/category/amount。每个 writer 的一次 UPDATE 涉及约 6,250 行,8 个 writer 同时执行时需要维护新索引。脚本虽然传入--ddl-timeout 180,但 writer readiness 实际硬限制为min(30, ddl_timeout),最多只等待 30 秒。失败 job 在该场景之前已经出现明确的服务迟滞:
Communications link failure;综合判断:本次失败与完整 nightly 长时间运行后的事务、checkpoint、索引维护或服务端排队压力高度相关,30 秒 writer readiness 门槛被慢 UPDATE 击穿;当前 run 不能用于判定 #27249 修复失效或问题重新出现。
由于两次 MatrixOne commit 不同,尚不能完全排除
344d852a..dc403fba之间引入了索引维护 UPDATE 性能退化。建议在全新 namespace 上固定dc403fbac6a09c77ac93bb023fe83056308a038b,只运行issue_26804_online_index_race:add_index=PASS后发生 writer readiness timeout,应先定位 UPDATE/索引维护性能问题;