You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Data Branch DAG construction does not stop cyclic parent metadata #26205
databranchutils.NewDAG calculates every node depth recursively, but the depth walk does not track nodes already visited on the current parent chain. A two-row circular parent relation therefore does not return from DAG construction.
The same file already applies a bounded parent walk in PathFromAncestor, but the construction-time depth calculation does not use an equivalent check.
Tested at origin/main commit 3f3cdcdda64fddb93b6668a301ff38d41e73fb76.
Reproduction
Run this minimal program three times in separate processes:
Each run exits with status 2 after repeating calculateDepth(101) and calculateDepth(102).
Actual result
NewDAG does not finish normally when the metadata parent chain loops.
Expected result
The DAG constructor should detect the repeated node in the current depth walk and return or construct a bounded invalid-DAG representation instead of recursively walking forever.
This was already fixed by #26139, merged as 7b4c81a. The reported origin/main commit 3f3cdcd predates that fix.
Verified again against the current main implementation at 6004bec:
TestNewDAGCycle passed under -race -count=3.
The complete pkg/frontend/databranchutils package passed under -race.
Coverage includes a two-node cycle, a self-cycle, a non-cyclic descendant of a cycle, and a 4,096-node acyclic chain.
calculateDepth now uses an iterative parent walk, detaches only repeated cycle members, and preserves valid descendant edges. Closing this duplicate as completed.
Activity
VioletQwQ-0 commentedon Jul 28, 2026
This was already fixed by #26139, merged as 7b4c81a. The reported origin/main commit 3f3cdcd predates that fix.
Verified again against the current main implementation at 6004bec:
TestNewDAGCyclepassed under-race -count=3.pkg/frontend/databranchutilspackage passed under-race.calculateDepthnow uses an iterative parent walk, detaches only repeated cycle members, and preserves valid descendant edges. Closing this duplicate as completed.Ariznawlll commentedon Jul 29, 2026
已在最新
main分支完成验证。测试版本:
52ea9f874f492c368a20efef16b46ab8ced2de37(fix: support cyclic foreign keys in database branch (#26292))测试过程:
执行 Data Branch DAG 循环依赖专项测试,覆盖两节点循环、自循环、循环节点下仍存在合法子节点,以及长链无环依赖。
普通模式连续执行 3 轮:
使用 race detector 再连续执行 3 轮:
测试结果:
-race测试全部通过,未发现数据竞争。结论:该问题在上述最新 main commit 上验证通过。
Ariznawlll commentedon Jul 30, 2026
已在
main@0ebba1c0c96bbcf0ff4091236e10df7b97e24a0c补充完成黑盒和白盒验证。白盒验证原始缺陷:
该 UT 在子进程中构造循环 parent metadata,验证
NewDAG能有界返回、循环节点被安全断开,且不会递归至 stack overflow。黑盒验证合法 happy path:
结果:该 case
38/38条 SQL/断言通过;本轮 Data Branch 全集13/13case、280/280条 SQL/断言通过。Unhappy path / 防护边界:
101 → 102 → 101的非法 parent cycle,要求NewDAG有界返回,不能无限递归或 stack overflow。结论:循环 catalog metadata 的内部失败路径由白盒 UT 覆盖,深层合法 DAG 的公开路径由 MOTR 黑盒覆盖;回归已加入 motr#69。
Ariznawlll commentedon Jul 30, 2026
Unhappy Path / 循环 DAG 专项验证
测试版本:
main@0ebba1c0c96bbcf0ff4091236e10df7b97e24a0c白盒直接构造非法 metadata:
验证要求:
NewDAG必须有界返回,不能无限递归或 stack overflow。反向 happy-path 控制:
结果:非法 cycle 白盒测试通过;合法 16 层黑盒用例
38/38条 SQL/断言通过。回归见 motr#69。