Repository navigation
Description
Summary
After a DATA BRANCH MERGE, the branch table keeps all its rows, but DIFF and PICK against that branch silently stop seeing the rows that were part of the merged delta — even when those rows still differ from the target table right now. Iterative branch workflows (merge, keep working on the same branch, diff/pick again) lose data without any error.
Environment: main@HEAD (c6683bd, built 2026-11-02), local etc/launch-multi-cn cluster.
Reproduction
CREATE TABLE m1 (k INT PRIMARY KEY, v VARCHAR(10));
INSERT INTO m1 VALUES (1,'a'),(2,'b');
DATA BRANCH CREATE TABLE m2 FROM m1;
INSERT INTO m2 VALUES (3,'new');
UPDATE m2 SET v='mod' WHERE k=1;
DATA BRANCH MERGE m2 INTO m1; -- works: m1 gets (1,'mod'),(2,'b'),(3,'new')
-- keep iterating on the same branch
DELETE FROM m1;
INSERT INTO m1 VALUES (1,'x');
INSERT INTO m2 VALUES (5,'postmerge');
DATA BRANCH PICK m2 INTO m1 KEYS (5); -- OK, k=5 lands in m1
DATA BRANCH PICK m2 INTO m1 KEYS (3); -- Query OK, **but k=3 never arrives** (row is physically in m2)
DATA BRANCH DIFF m2 AGAINST m1;Current state at DIFF time: m2 = (1,'mod'),(2,'b'),(3,'new'),(5,'postmerge'), m1 = (1,'x'),(5,'postmerge').
True current differences: k=1 value conflict, m2-only k=2 ('b') and k=3 ('new').
Actual DIFF output — k=2 and k=3 missing entirely, plus a phantom INSERT for k=1 which exists on both sides:
('m2', 'UPDATE', 1, 'mod'),
('m1', 'UPDATE', 1, 'x'),
('m1', 'INSERT', 1, 'mod') -- k=1 exists in BOTH tables; phantom
Expected vs actual
| operation | expected | actual |
|---|---|---|
PICK m2 INTO m1 KEYS (3) after a prior merge of k=3 |
row (3,'new') copied to m1 | statement OK, nothing copied |
DIFF between branch and target |
compares current contents | only reports deltas newer than the last MERGE; rows consumed by a prior merge are invisible, and a phantom INSERT appears for a key present on both sides |
The first DIFF/MERGE/PICK cycle on a fresh branch is fully correct (verified: create → modify → DIFF shows precise UPDATE/DELETE/INSERT → MERGE applies them; conflict options SKIP/ACCEPT/FAIL all behave). The defect only appears after the first MERGE — the delta tracking seems to be consumed by MERGE without retaining a baseline for subsequent comparisons, so follow-up DIFF/PICK operate on "changes since last merge" instead of "current branch vs target".
Control: re-creating the branch (DATA BRANCH CREATE TABLE m3 FROM m1 on the current target) and picking from the fresh branch works.
Why this matters
The feature presents a git-like workflow (branch → merge → keep working → merge again). Under that workflow, any row merged once can never be diffed or picked again, and the failure is silent — statements return OK while rows are skipped. Users converging long-lived branches will lose track of real differences.
Activity
[-][Bug]: data branch DIFF/PICK ignore rows consumed by a prior MERGE[/-][+][Bug]: data branch DIFF/PICK lose track of rows after the first MERGE[/+]Ariznawlll commentedon Nov 2, 2026
Follow-up with the semantics pinned down. DIFF is a three-way (git merge-base style) comparison, not a full-content diff — verified with a fresh branch:
So on a fresh branch each side's post-branch changes are reported correctly. The defect is specifically that after the first MERGE, the base state is wrong, producing three symptoms in the iterative workflow (repro in the issue body):
MERGE m2 INTO m1, runningDELETE FROM m1(which removes k=1,2,3) then re-inserting only k=1 yields a DIFF that reports the k=1 UPDATE but omits the k=2 and k=3 deletions entirely — while the same deletion on a fresh branch (case A above) is reported fine.('m1','INSERT',1,'mod')although k=1 exists in the base and in both tables).PICK m2 INTO m1 KEYS (3)returns OK but copies nothing; keys inserted into m2 after the merge pick fine).All three are consistent with the merge-base/LCA not being advanced (or being advanced to the wrong state) by MERGE: the branch's pre-merge changes are still reported as pending, the target's new deletions vanish, and PICK can only see post-merge deltas. Suspect area:
pkg/frontend/data_branch_hashdiff.go(hashDiffIfHasLCA/ LCA probe) and wherever MERGE records the new base.fix(data branch): honor table clear boundaries in DIFF and PICK (#33233)
XuPeng-SH commentedon Nov 26, 2026
QA 交接(main,待验收)
#33233 已合入 main,
484af86688d346de9029533e224748a7f409f626。无条件 DELETE 可能走和 TRUNCATE 相同的物理换表路径;旧 Data Branch 把该边界当作保留行的 ALTER,导致后续 DIFF 漏报删除、PICK 返回成功却漏行。修复在已有 lineage 中记录清空边界,并按比较快照恢复增量;不追溯改写历史 ALTER。请在含该合并提交的版本上复测原序列:MERGE 后清表重插,再 PICK 已合并的键和新键,核对实际目标行和 DIFF 三方结果;再对照 TRUNCATE、普通逐行 DELETE、保留行的 COPY ALTER、限定上界的 PICK、重启或 GC 后的快照读取。目标后加列要保留已有值,插入则采用目标默认值。
PR 作者在先前
f42550e报告 385/385 BVT、295 项聚焦单测及嵌入式 SQL 通过,ee35455的上界快照回归另有本地结果和 mo-bot 通过;合并前最新 head 有上游更新。本轮未独立运行合并 SHA 的 SQL 或多 CN/Proxy,不以转测代替验收。Ariznawlll commentedon Nov 28, 2026
结论
测试通过。main上的原始DIFF/PICK、三种清空边界、历史上下界、三轮真实优雅重启及实际GC恢复均完成;MOTR和修正测试夹具挂载后的Linux功能/白盒门槛均通过,按授权关闭。
关键证据
分支与版本
484af86688d346de9029533e224748a7f409f626。本项只按 main 验收。3cb7a5e4a93dc5bd85e0fb107e558a07df934693,两个独立进程 CN 的git_version()均核对完整 SHA;保留既有工作区和其他实例。679c314000edc9ca7ef55cc90905a87f44ad2669;相对本地冻结版新增Sirius配置/说明与window append type-ops变更,没有改变Data Branch SQL实现。Linux CI 另在启动时核对其实际官方 main 完整 SHA。首次 MERGE 后清空,再 DIFF/PICK
每个独立数据库分别执行三条清空路径:
DELETE FROM dst、TRUNCATE TABLE dst、带条件删除所有既有行。步骤如下:每个变体的目标精确返回:
DIFF 精确核对三项,不只检查行数:源侧 UPDATE
(1,mod)、目标侧 UPDATE(1,x)、目标侧 DELETE(2,b)。尤其确认先前已经 MERGE 的 key=3 可再次 PICK 恢复,而不是仅覆盖 MERGE 后新加的 key=5。另一 CN 新连接读回相同结果。COPY、历史界限与拒绝后的状态
ALTER ... ALGORITHM=COPY不得误判为清空。单侧新增列时,DIFF 正确拒绝不兼容 schema;两侧对齐相同列后 DIFF 精确为空。(1,new),(2,added),创建上界快照;随后才新增 note 列及 key=3。按 BETWEEN 两快照 PICK,最终精确为(1,new,local),(2,added,default);保留目标既有 note,新增目标行用目标默认值,排除上界以后的 key=3。(1,new),(2,added)。DEFAULT CURRENT_TIMESTAMP(6)扩展,DIFF 返回cannot establish historical value,再次读取目标证明原内容未改变。三轮真实服务重启
本地另外做了三次服务生命周期,每次三个新建独立数据库,共九组完整夹具。每次先核对本任务进程 PID/命令和二进制 SHA256,再只对本任务的两个 main 进程发送 SIGTERM。未强杀,重用同一二进制、配置、服务 UUID 和数据目录,两个 CN 都核对 SQL ready 和完整 git_version() 后再验收。
三次均验证:当前目标完整行集、上下界历史快照、原始 PICK 行集;重启后再删目标 key=2、重新执行原 bounded PICK,精确恢复该行及默认列。九组全部通过,之后删除各自快照和数据库。
这里验证的是实际进程的优雅退出/重启,不是断电、SIGKILL、跨机 fencing 或 Chaos,不将场景扩大表述。
已有磁盘 GC / recovery 白盒集成
同一冻结源码,Go1.27.1 / main ARM 官方 SIMD 配置执行:
两个根测试各 3/3。覆盖 5,000 基础行、1,000 新行,实际旧物化对象被 GC 回收的命中证据,以及 GC 后 DIFF 和服务恢复后的正确性。没有把一次无 GC 的普通查询等同于这部分验证。
回归交付与 CI
07c0f301b204722f56a80704c03a2eec720627b8;未向 MatrixOne 主库提交测试 PR。script/12_git4data/issue_32003_clear_boundaries.py和对应 out,包含三种清空、精确 DIFF/PICK、COPY、上下界及历史默认值拒绝检查;快照生命周期按 exclusive 执行。total=3 success=3 failed=0 skipped=0,8.19 秒。Verify Data Branch clear boundaries and bounded PICK已SUCCESS;同run恢复/GC测试因builder的.dockerignore排除test目录、两个既有测试缺SQL/result文件而失败,未到相应产品断言。已在MOTR只读挂载同一pinned官方checkout的test目录并显式核对四文件存在,原断言不变;新46127601037的本单SQL和恢复/GC门槛均SUCCESS。MOTR_HASHBUILD_RUNNER而失败,未执行该产品大内存场景。它不属于本单功能结果,不能将整条 PR CI 写成全绿。修正夹具挂载后的最终Linux门槛
46127601037,MOTR head
07c0f301b204722f56a80704c03a2eec720627b8,实际官方main679c314000edc9ca7ef55cc90905a87f44ad2669:Go step显式检查两个根各三个PASS,原SQL/result夹具从同一pinned官方checkout只读挂载,没有改产品实现或放松断言。此前缺夹具失败保留,不能称旧run整体通过;最终使用本次新门槛作为验收证据。
待解决点
本单原始问题及必要恢复扩展无未通过项、无未验收项。MOTR汇总PR尚待合入;独立HashBuild缺runner及其他Issue长耗时检查不属于本单通过证据,不宣称整个PR全绿。
最终结论:测试通过。main清空后的精确DIFF/PICK、旧MERGE键恢复、COPY对照、历史上下界/默认值、三次真实优雅重启九组夹具及两个GC/recovery根各三轮全部通过;Linux功能和恢复/GC门槛也已通过。未通过项:无;未验收项:无。回归已提交MOTR main #374,按授权关闭。
test(embed): eliminate redundant branch clear race work (#33581)