Repository navigation
Description
Description
DATA BRANCH DIFF cannot read a live branch after storage GC and a service restart. A minimal one-edge branch is sufficient: the pre-restart DIFF is correct, while the first post-restart DIFF fails during history lookup even though both tables and the branch protection record remain present.
Environment
- Branch:
main - Commit:
dd040ad6913e9b86f592b574e5fffb610003f72a - Deployment: local single-process topology (1 CN, 1 TN, 1 Log Service), local filesystem storage
- Test date: 2026-08-22
Steps to reproduce
create database db_gc_restart;
use db_gc_restart;
create table root(id int primary key, v int);
insert into root values (1,1),(2,2),(3,3),(4,4);
data branch create table leaf from root;
update root set v=101 where id=1;
delete from root where id=2;
update leaf set v=303 where id=3;
insert into leaf values(5,505);
-- Before lifecycle actions this returns four changes.
data branch diff leaf against root output count;
select mo_ctl('dn','flush','db_gc_restart.root');
select mo_ctl('dn','flush','db_gc_restart.leaf');
select mo_ctl('dn','globalcheckpoint','');
select mo_ctl('dn','diskcleaner','force_gc');
-- Still returns four before restart.
data branch diff leaf against root output count;
-- Gracefully restart this local MO service, then reconnect.
data branch diff leaf against root output count;Actual behavior
The post-restart DIFF fails with:
HY000 / 20101: internal error: cannot find database <id> (db_gc_restart) created_time at snapshot <ts>
The failed read does not alter visible data: in the expanded chain matrix, the root table retained 3 rows, the leaf retained 5 rows, and 2 branch-protection records remained present after every failure.
Expected behavior
GC and restart must not invalidate history required by a live Data Branch. The post-restart DIFF should return the same four changes as before restart.
Stability and controls
- Minimal one-edge reproducer with GC + restart: 3/3 failed on latest
main. - Expanded
root -> middle -> leaflifecycle matrix with GC + restart: 10/10 failed; each run passed the pre-restart DIFF. - Same expanded topology with restart but without GC: 3/3 passed, including exact DIFF results and subsequent branch-history reclamation.
- Failure checks: both table contents and branch protection metadata remained intact after each error.
- No branch-table
mergeobjectsis required. This distinguishes the issue from [Bug]: DATA BRANCH DIFF loses history after branch-table mergeobjects and GC #27451, which requires branch-table compaction and fails with a missing object error before restart.
Evidence
DataBranchGcRestartDirectProbe.java: minimal 3-run matrix.DataBranchProtectRecoveryProbe.java: 10-run chain matrix plus 3-run restart-only control.
Code analysis
Confirmed failure site: getDatabaseCreatedTimeLowerBoundByPK in pkg/frontend/data_branch.go scans mo_database at the branch history timestamp and raises this error when it cannot find the database creation timestamp.
Hypothesis: after GC/restart, the snapshot catalog scan used to derive the collection lower bound no longer sees the still-live database's historical creation record. The helper was introduced by #24371 while optimizing arbitrary-DAG collection ranges; the fallback or retention path should preserve a usable lower bound for a live branch.
Regression coverage
After the fix, add a deterministic case under motr/suites/12_git4data / test/distributed/cases/git4data/branch/diff/ that creates a one-edge branch, advances flush/checkpoint/GC, restarts the service in the appropriate recovery workflow, and asserts exact post-restart DIFF rows plus table/protection state.
Related
- fix: data branch diff returns wrong results after GC+restart #24010 — earlier GC/restart Data Branch DIFF repair; this is a new recurrence with a different failing path.
- [Bug]: DATA BRANCH DIFF loses history after branch-table mergeobjects and GC #27451 — distinct branch-table-compaction/GC history loss without restart.
Activity
gouhongshen commentedon Aug 22, 2026
Triage decision: defer.
Reason: the reported GC-and-restart failure cannot currently be reproduced or proved with an executable regression, so an active s0 fix would be speculative.
Current evidence: (1) the issue SQL ran on current main through flush, global checkpoint, forced disk GC, a full mo-service process restart, and reconnect; DATA BRANCH DIFF returned the exact four rows, root/leaf retained 3/5 rows, and the branch protection row remained present; (2) the same one-edge lifecycle executed against the reported dd040ad code in an isolated storage-backed cluster and reached post-restart DIFF without the reported database-created-time lookup error; its only failure was an embedded-recovery protection-snapshot identity mismatch, which is not evidence for this issue; (3) a direct dd040ad mo-service binary was built, but its fixed launch ports were concurrently occupied by an unrelated in-progress local test, so no direct old-binary run was possible without changing that tests service scope.
Attempted test construction: a deterministic Go integration case covering the exact DDL/DML, flush/checkpoint/force_gc, full restart, exact DIFF count and rows, table contents, and protection state. It was not retained because it passed the reported DIFF behavior on the investigated revisions and therefore cannot prove a new fix.
To promote later: provide a reproducible data directory/configuration or a failing executable case on current main that reaches getDatabaseCreatedTimeLowerBoundByPK after restart; then a focused root-cause fix and regression can be safely validated.
gouhongshen commentedon Sep 4, 2026
Triage decision: defer.
Reason: the reported GC-and-restart failure still cannot be reproduced or turned into a failing executable regression, so changing the catalog-history path would be speculative.
Current evidence: I built the exact reported commit
dd040ad6913e9b86f592b574e5fffb610003f72aand ran its realmo-servicein an isolated local single-process topology with persistent filesystem storage. Three independent rounds executed the issue’s minimal DDL/DML, verified the four-change DIFF before lifecycle actions, flushed both tables, forced a global checkpoint and disk GC, verified DIFF again, gracefully stopped the full service, restarted it over the same data directory, and reconnected. All 3/3 post-restart runs returned count 4; exact rows wereroot UPDATE (1,101),root DELETE (2,2),leaf UPDATE (3,303), andleaf INSERT (5,505). Root/leaf row counts stayed 3/5 and the live branch-protection row count stayed 1. This closes the earlier direct-old-binary evidence gap; prior investigation also passed the same lifecycle on current main and in an isolated storage-backed integration fixture.Code findings:
getDatabaseCreatedTimeLowerBoundByPKand its “cannot find database ... created_time at snapshot” failure remain present at the reported commit and current main. No intervening change explains a distinct fix for that lookup. Since the exact public reproducer does not reach the failure even on the reported revision, there is no demonstrated violated invariant from which to derive a safe production change.Attempted regression construction: the deterministic integration scenario covers the exact DDL/DML, pre-GC DIFF, flush/checkpoint/force-GC, full process restart, exact post-restart DIFF rows/count, table contents, and protection metadata. It passes on the reported revision, so retaining it as proof of a new fix would be invalid. A BVT file also cannot itself restart the owning service; the appropriate recovery harness was exercised directly instead.
To promote later: provide the failing data directory and launch configuration, or a deterministic case on current main that reaches the database-created-time lookup failure after restart. That evidence can identify the missing retention/state transition and support a focused fix plus a regression that fails before the change.
44 remaining items
gouhongshen commentedon Oct 16, 2026
PR #30410 is trying to fix this issue.
style(embed): defer-close query rows in data branch restart test (mat…
fix(embed): cancel heartbeat context on stop so teardown joins prompt…
test(embed): cover data branch DIFF across GC, checkpoint, and restart (
gouhongshen commentedon Oct 17, 2026
PR #30410 has merged and is awaiting manual validation. The issue remains open.
XuPeng-SH commentedon Oct 17, 2026
本轮实际执行验证(2026-10-17,main
d9cf2dd4e2b92e2193bb390115be624b76099764,Linux/amd64、Go 1.27.1、匹配 make cgo 产物):mo-cgo-test -p 2 -count=1 -tags matrixone_test -json -timeout=25m -run '^(TestDataBranchDiffAcrossCheckpointGCAndRestart|TestRecoveryClusterStartupBudget)$' ./pkg/embed返回 PASS,生命周期根测试 219.80s:gc_checkpoint_restart:200.60s,通过原 issue 的一边 branch SQL、完整 DIFF 行和 OUTPUT COUNT、当前表数据及 branch protection 检查;探针真实对象文件在 70 轮 checkpoint 检查后、2m57.824s 内被物理回收,随后两次完整集群 Close/Start 后的断言均通过。没有将 force_gc 返回 OK 当作 GC 完成证据。checkpoint_restart:11.80s,通过;flush_only_restart:7.40s,通过。两项独立集群保留生产 1h GC TTL,对照结果未依赖 GC 场景状态。TestRecoveryClusterStartupBudget全部 6 个子场景通过,另外单独-race -count=1执行同一根测试也通过。#30410 是回归覆盖,生产修复此前由 #29867 落地;本轮实测证明当前 main 上报告的嵌入式恢复场景通过,不将测试代码描述成新的生产修复,也不扩展为未执行的多进程/远程部署验证。按约定将 #27465 转给 @Ariznawlll 继续测试确认。
Ariznawlll commentedon Oct 17, 2026
测试版本
main7c2847207dc5bd87f6c23dc7318f7be21c0a5f2amo-service的 MySQL 6001 运行 MOTR SQL。原问题验证
已确认生产修复 PR #29867 进入本次官方 main,PR #30410 增补生命周期回归测试。独立执行
TestDataBranchDiffAcrossCheckpointGCAndRestart -count=3,总计 610.476 秒、3/3 根测试通过。每轮gc_checkpoint_restart均按原 issue 建立 root/leaf 一边分支,产生 root UPDATE(1,101)、DELETE(2,2) 与 leaf UPDATE(3,303)、INSERT(5,505) 共 4 条差异;执行 flush、global checkpoint、force_gc,并通过探针对象文件实际消失证明物理 GC 完成,之后完整集群 Close/Start 两次,每次仍能读取 4 条精确 DIFF 及 OUTPUT COUNT=4、root 3 行、leaf 5 行、branch protection 1 条。没有把force_gc返回 OK 当作 GC 已完成。Happy Path 覆盖
(1,101),(3,3),(4,4)、leaf(1,1),(2,2),(3,303),(4,4),(5,505);MOTR 成对用例定向 3/3,45/45 语句通过。checkpoint_restart及flush_only_restart各自在独立集群中按精确差异、行数与保护记录断言通过;各 3/3。GC 主路径两次重启后仍保持正确,3/3。Unhappy Path 覆盖
白盒验证
运行的是合入后的生产集成测试
pkg/embed/branch_checkpoint_restart_test.go,不是 mock 返回值;该测试实际检查物理探针对象回收、完整服务重启和 SQL DIFF 值。-count=3PASS。#30410 的 PR 说明亦提供仅回退 #29867 关键 guard 时复现 20101 的负对照,本轮未对官方 main 改写生产代码。回归测试
TestDataBranchDiffAcrossCheckpointGCAndRestart,3/3;独立环境执行的 GC/重启路径不放进共享 MOTR,以免对其他测试执行全局清理。suites/14_issue_regression/t/issue_27465_data_branch_diff_lifecycle_surface.test与r/issue_27465_data_branch_diff_lifecycle_surface.result,已追加汇总 PR #247,head086bfdaf;定向 3/3、45/45 语句,覆盖原始分支/DIFF 值但不冒充 GC/重启。PR 尚未合入,完整 suite/共享集成 CI 尚未通过。测试证据
/private/tmp/mo-30265-qa-adWo0K:go test -tags matrixone_test -count=3 -timeout=25m -run '^TestDataBranchDiffAcrossCheckpointGCAndRestart$' ./pkg/embed返回ok ... 610.476s;MOTR 本地 runvar/log/run-1792255950874343000返回total=3 success=3 failed=0 skipped=0。测试结论
测试通过。