Skip to content

[Bug]: DATA BRANCH DIFF against older ancestor snapshot produces incorrect diff #32968

Done

Description

@VioletQwQ-0

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

d2e7103

Other Environment Information

- Hardware parameters: Apple Silicon (darwin/arm64)
- OS type: macOS (reproducible in standalone local mo-service / BVT)
- Others: DATA BRANCH DIFF / MERGE / PICK with SNAPSHOT clauses

Actual Behavior

  1. When comparing a cloned/branched table against an earlier ancestor snapshot taken before the branch forked (T_old < CloneTS), DATA BRANCH DIFF t1 AGAINST t0{snapshot='diff_older_ancestor_sp'} produces incomplete or incorrect rows:
    • Ancestor changes written between T_old and CloneTS are omitted or attributed using the wrong snapshot/probe timestamp;
    • LCA deletion probing uses stale schema/column names across in-place RENAME COLUMN, or passes MO_TS=<int64> instead of {MO_TS='<TS.ToString()>'}, or opens fallback/historical readers at the current transaction timestamp instead of the endpoint/LCA snapshot;
    • Historical BETWEEN SNAPSHOT collection mis-tracks per-segment identities/snapshots during self-ancestor/compaction paths;
    • DATA BRANCH MERGE ... INTO dst{snapshot=...} is not rejected explicitly when a destination snapshot is supplied.

Expected Behavior

  • DATA BRANCH DIFF (and symmetric comparisons / OUTPUT SUMMARY / COPY ALTER / composite PK / fake PK / PICK paths) comparing a branch against an older ancestor snapshot (T_old < CloneTS) accurately computes the net diff between both snapshots, resolves column names visible at each probe/endpoint snapshot across renames, binds fallback readers to the historical snapshot, and rejects DATA BRANCH MERGE with a destination snapshot option cleanly.

Steps to Reproduce

drop snapshot if exists diff_older_ancestor_sp;
drop database if exists test_diff_older_ancestor;
create database test_diff_older_ancestor;
use test_diff_older_ancestor;

create table t0(id int primary key, v int);
insert into t0 values (1,10),(2,20),(3,30),(4,40),(5,50);
create snapshot diff_older_ancestor_sp for database test_diff_older_ancestor;

update t0 set v = v + 1 where id in (1,3);
delete from t0 where id = 2;
insert into t0 values (6,60),(7,70);

data branch create table t1 from t0;
update t1 set v = 30 where id = 3;
update t1 set v = 41 where id = 4;
delete from t1 where id in (5,7);
insert into t1 values (8,80);

-- Compare cloned branch t1 against pre-fork snapshot of t0
data branch diff t1 against t0{snapshot='diff_older_ancestor_sp'};
data branch diff t0{snapshot='diff_older_ancestor_sp'} against t1;

And with an in-place column rename across the older snapshot:

create table r0(id int primary key, v int);
insert into r0 values (1,10);
create snapshot diff_older_ancestor_sp for database test_diff_older_ancestor;
data branch create table r1 from r0;
alter table r0 rename column v to w;
data branch create table r2 from r0;
delete from r1 where id = 1;
delete from r2 where id = 1;
data branch diff r2 against r0{snapshot='diff_older_ancestor_sp'};
data branch diff r0{snapshot='diff_older_ancestor_sp'} against r2;

Additional information

Observed during DATA BRANCH historical snapshot diff/merge/pick regression testing (single-table self-snapshot diffs, pre-fork ancestor snapshots, and sibling renames).

Activity

  1. added
    kind/bug
    on Nov 20, 2026
  2. XuPeng-SH commented on Nov 24, 2026

    @XuPeng-SH
    Contributor

    转 QA 验证:PR #32970 已合入 main,merge 835455b3ad06ffcc6936fdc0b55fae3dd97cc161。修复分支与 fork 前祖先快照的双向 DIFF、历史 LCA 表身份/列名与读者快照一致性,以及 MERGE 目的端快照的拒绝路径。

    证据:PR 报告早期候选 ec76fb92 的重点 BVT 103/103,55 个分支回归脚本 4,429/4,429;独立评审 3967ea75 通过前端 127 项/218 子项,并从冻结 CI 核对两个多 CN BVT。对比最终 head 1d4fa013 的新增提交未改变 data_branch/older-ancestor 相关文件;最终 head 可见 Iceberg 和 Connector/J 检查通过。本轮未运行合并 SHA 的本地或真实 QA。

    请用包含该 merge 的 main 从实际 SQL 入口核对双向净差/summary,重点覆盖 fork 前后增删改、列重命名后同名异表不得错读、历史 reader fallback、兄弟分支 PICK,以及目的 SNAPSHOT 的 MERGE 拒绝后无写入。PR 列明的既有事务/COPY ALTER 组合和 OUTPUT FILE 独立问题不作为本单“已修复”项。

  3. Ariznawlll commented on Nov 24, 2026

    @Ariznawlll
    Collaborator

    结论

    验收通过,关闭本 Issue。branch/clone 与 fork 前祖先快照 的双向 DATA BRANCH DIFF 已按净差返回正确结果;历史表身份、列重命名、reader snapshot、summary、sibling PICK 以及目的端带 SNAPSHOT 的 MERGE 拒绝路径均已由专项 SQL 回归覆盖。

    修复与有效测试版本

    • 修复 PR fix(data branch): compare clones against older ancestor snapshots #32970 已合入 main,merge commit:835455b3ad06ffcc6936fdc0b55fae3dd97cc161。
    • 决定性 CI 为 run 45373381707,实际 head:3967ea75318b7397c008d7599909366395571c39。CI Required、UT、Coverage 和两套 multi-CN BVT 均成功。
    • 已逐文件核对 3967ea75318b7397c008d7599909366395571c39 → 最终 PR head 1d4fa013 → merge 835455b3:data branch 相关源码及专项 SQL/result 的相关树完全一致。本结论使用的是同相关树提交的实际 CI 结果,不是声称在 merge SHA 上重新做了本地验收。

    原场景专项证据

    直接读取 pessimistic multi-CN BVT artifact:

    • git4data/branch/diff/diff_older_ancestor_snapshot.sql:131/131,FAILED=0,IGNORED=0。

    该专项覆盖:

    • 原 SQL 的双向 older-ancestor DIFF 与 OUTPUT SUMMARY。
    • fork 前后增删改、intermediate branch 和净差归属。
    • fake PK、composite PK 及 COPY ALTER 路径。
    • in-place RENAME COLUMN、同表历史快照,以及历史表名被另一张表复用时不得错读。
    • sibling PICK 及各自 fork generation。
    • DATA BRANCH MERGE ... INTO dst{snapshot=...} 明确拒绝,且拒绝后目标数据保持不变。

    同一提交的独立前端定向评审另通过 127 个 tests / 218 个 subtests,覆盖历史 identity、snapshot mismatch、rename 和单次 lookup;这是辅助证据,不替代上述 SQL artifact。

    范围边界

    PR 已明确的既有事务组合、COPY ALTER ADD + pre-fork rename 和 OUTPUT FILE 独立问题不在本次“已全部修复”的声明内。最终 head 的另一运行被取消也不写成绿色或产品失败;本次关闭仅依据上述同相关树、已实际通过的 131 项专项回归及其明确覆盖范围。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triagephase/testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions