Repository navigation
Description
MatrixOne version
bdcada5438 (2026-08-09), local single-node deployment, 6 GiB memory cache.
What happened?
A failed ALTER TABLE ... ADD UNIQUE INDEX after online index DDL and concurrent indexed UPDATEs made previously invisible UPDATE versions visible in the base table. The table grew from 300,000 to 325,000 logical rows and now returns duplicate composite primary keys. Existing hidden indexes remain at 300,000 rows, so the base table and all physical indexes disagree.
This is persistent logical corruption, not only an incorrect duplicate diagnostic.
Sequence
The table has:
PRIMARY KEY(tenant_id,row_id),
UNIQUE KEY uq_ddl_external_tenant(external_key,tenant_id),
KEY idx_ddl_tenant_status_pk(tenant_id,status,row_id),
KEY idx_ddl_row_tenant_reverse(row_id,tenant_id)- Insert 300,000 rows;
row_idandexternal_keyare globally unique. - Run four concurrent autocommit UPDATE writers changing
status,category,amount, andupdated_at, plus readers. - While writers run, add
(status,category,amount,row_id,tenant_id). Stop writers after 8 seconds. ADD succeeds in 9.62 seconds. - Repeat bounded writers while dropping
idx_ddl_tenant_status_pk. DROP succeeds in 9.16 seconds. - Verify
COUNT(*)=300000,COUNT(DISTINCT row_id)=300000, all readers match, and the new physical index is300000 / 300000 distinct key / 300000 distinct PK mapping. - With no writers remaining, run:
ALTER TABLE idx_ddl_probe
ADD UNIQUE INDEX uq_ddl_category_row_tenant(category,row_id,tenant_id);This key is logically unique because row_id is globally unique. The statement incorrectly fails:
ERROR 1062: Duplicate entry '(cat-9,37,37)' for key '__mo_index_idx_col'
A second intentionally failing unique build on status was then issued. Both failed index names were correctly absent from the catalog, but the base table had become corrupted.
Post-failure evidence
SELECT COUNT(*),COUNT(DISTINCT row_id) FROM idx_ddl_probe;
-- 325000, 300000
SELECT COUNT(*) FROM (
SELECT tenant_id,row_id FROM idx_ddl_probe
GROUP BY tenant_id,row_id HAVING COUNT(*)>1
) d;
-- 25000
SELECT tenant_id,row_id,category,status,amount
FROM idx_ddl_probe WHERE row_id=37;
-- 37,37,cat-8,3,0.5100
-- 37,37,cat-9,4,0.5200The duplicate PK groups are exactly all 6,250 rows from tenants 4, 15, 26, and 37, corresponding to one UPDATE generation from each of the four writer streams.
Direct physical audit after corruption:
| object | rows |
|---|---|
| base table | 325,000 |
idx_ddl_row_tenant_reverse hidden table |
300,000 |
idx_ddl_status_category_amount_pk hidden table |
300,000 |
uq_ddl_external_tenant hidden table |
300,000 |
Before the failed unique DDL, the same hidden tables and the base table were all 300,000. A fresh 20,000-row control with four sequential UPDATE generations can add the same logical unique key successfully; the online ADD/DROP + concurrent UPDATE history is relevant.
Expected behavior
Failed index DDL must be fully atomic and must never change base-table visibility. A unique-index builder must scan one current committed version per primary key. On failure, cleanup must affect only temporary index data.
Suspected risk area
The unique-index build or rollback path appears to publish/backfill rows from a stale snapshot or reuse an intermediate DDL relation in a way that resurrects one UPDATE generation. Please audit snapshot ownership, sink/rollback targets, and ADD/DROP index transaction cleanup.
Required regression checks
- bounded concurrent indexed UPDATEs during ADD and DROP;
- successful ADD/DROP followed by logically valid and intentionally invalid unique builds;
- base count and duplicate composite-PK groups before/after every failure;
- existing hidden table count, distinct encoded key, and distinct PK mapping;
- retry, flush, restart, and rollback durability;
- multiple writer generations and writer counts.
Activity
XuPeng-SH commentedon Aug 9, 2026
Fresh minimization/race results narrow the trigger but do not yet reproduce the corruption deterministically.
Two clean 300,000-row trials repeated the same operation classes, including a higher-pressure variant:
(status,category,amount,row_id,tenant_id)and DROP of(tenant_id,status,row_id);(category,row_id,tenant_id);(status).The valid build succeeded and the invalid build returned duplicate entry; after every stage:
A 120,000-row 4-writer/4-reader control was also clean. The original corrupted table remains persistently
325000 / 300000across many service restarts, so the report is still valid; these negative controls show that row count and operation class alone are insufficient and the failure is a low-probability transaction/DDL timing race. A regression/fix must use repeated fresh generations and must not overfit the one captured schedule.fix(tae): fail closed on transferred tombstone writes
fix(tae): fail closed on transferred tombstone writes
fix(tae): fail closed on transferred tombstone writes
fix(tae): fail closed on transferred tombstone writes (#26905)
Ariznawlll commentedon Aug 14, 2026
测试版本
main,commit43923c5e64abdc174f82ef4055ca653e501c3d34。c3ba9c7df14388956cb38d78681c6c35b75c42b8);测试版本位于修复之后。issue_26804_online_index_race.py。原问题验证
本轮按原问题的核心触发条件执行在线索引 DDL 与并发 UPDATE,并在 DDL 完成后立即审计基表主键完整性。
测试步骤:
创建
idx_ddl_probe,声明复合主键(tenant_id, row_id),同时创建一个唯一二级索引和两个普通二级索引。写入 300,000 行初始数据:
tenant_id = row_id % 48,row_id为 1~300,000,external_key全局唯一。DDL 前检查:基表行数、主键 distinct 数量及重复主键分组数;该阶段通过,重复主键分组数为 0。
启动 8 个独立 autocommit UPDATE writer,分别持续更新 tenant
4、15、26、37、0、11、22、33。UPDATE 只修改status/category/amount/version/payload/updated_at,不修改任何主键列。writer 运行期间在线执行:
ADD INDEX 成功返回且索引 catalog 可见后,立即按真实声明主键审计:
实际结果:第 1 个 generation 即发现 50,000 个重复主键分组,触发 fail-fast,原问题仍可稳定命中,验收不通过。
该数量与测试数据严格对应:300,000 / 48 = 6,250 行/tenant,8 个 writer tenant × 6,250 = 50,000。原 issue 使用 4 个 writer 时出现 25,000 个重复主键分组,本轮扩大到 8 个 writer 后得到 50,000,现象与原缺陷模式一致。
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
本轮未重新执行 MatrixOne 白盒测试;本轮结论来自最新
main上的 TKE 分布式黑盒并发回归。修复 PR #26905 已包含 transferred tombstone sink/事务路径的单元与 race 测试,但当前黑盒测试仍出现数据完整性失败,因此白盒用例不能替代本轮产品行为证据。建议研发结合
transferred_tombstone_sink的错误传播、同步时序及跨 CN 可见性继续定位。回归测试
--rows 300000 --writers 8 --writer-seconds 8 --generations 10 --ddl-timeout 180。_cffi_backend在产品测试前失败;PR 已显式安装cffi/cryptography/pymysql,本次运行环境构建和脚本启动均成功,因此当前 50,000 个重复主键分组是有效产品测试结果,不是依赖安装失败。测试证据
CI Run:31786586823
并发测试 Job:94725032612
关键日志:
测试结束后的资源清理 Job 成功,测试环境已回收。
最新
main已包含 PR #26905,但在 300,000 行、8 个并发 writer、2 CN 的在线 ADD INDEX 场景中,第 1 个 generation 即产生 50,000 个重复复合主键分组。该结果与 writer 覆盖的数据量完全一致,且 DDL 前审计为 0,说明原始数据完整性问题仍然存在。测试结论
测试不通过。
fix: prune tombstones using merge snapshot (#27173)
Ariznawlll commentedon Aug 16, 2026
验证结果
针对本 issue,在最新 MatrixOne main 上完成了大数据并发回归复核。
执行结果
覆盖内容
该回归属于 nightly big-data/concurrent 覆盖,用于验证大数据量下在线索引变更与并发写入的稳定性;本次不涉及 Chaos 故障注入。
补充:旧的本地 4.0-dev 二进制曾在初始化阶段因隐藏索引尚未完成构建触发 0 行审计失败;切换到上述最新 main 后,1 generation 预检及完整 10 generations 均通过,因此旧结果不作为本 issue 的产品失败结论。
测试结论
测试通过。
Ariznawlll commentedon Aug 16, 2026
大数据量回归添加位置
本 issue 的大数据量回归已加入 mo-nightly-regression PR #1365 的 nightly CONCURRENT TEST 流程,具体位置如下:
因此该 case 的归类是 nightly big-data/concurrent 回归,不是 Chaos 测试;定时 nightly 主调用默认执行,其他调用方可按 selector 选择执行。
fix(tae): fail closed on transferred tombstone writes (matrixorigin#2…
fix: prune tombstones using merge snapshot (matrixorigin#27173)
fix(tae): fail closed on transferred tombstone writes (matrixorigin#2…
fix: prune tombstones using merge snapshot (matrixorigin#27173)
fix(tae): fail closed on transferred tombstone writes (matrixorigin#2…
fix: prune tombstones using merge snapshot (matrixorigin#27173)